title: what is the code below all about? Android Surface View
body: <p>I want to create a compass using Surface View and I found that code below...but I don't know what the code below is trying to achieve, any ideas? </p>
  
  <p>It is a implemented method. I think the method should be called once and the thread runs forever unless the onPause method is called...but when i tried to run the code below the Paint class is called only once and then exit...the update for the position of the sensors are disregarded. Please help.</p>
  
  <pre><code>@Override
  public void surfaceCreated(SurfaceHolder holder) {
      // TODO Auto-generated method stub
  
      this.runDrawingThread = true;
  
      new Thread(new Runnable()
      {
  
        public void run()
        {     
              long l1 = System.currentTimeMillis();
              long l2 = 0L;
              int i = 0;
              int j = 0;
              long l3 = System.currentTimeMillis();
  
              if (!Painter.this.runDrawingThread){            
                return;
              }
              if (j &lt; 2)
              {
                Painter.this.onPaint(l3, true);
                j++;
                if ((l3 - l2) / 1000L &lt; 1L)         
                l2 = l3;
              }
  
              for (i = 0; ;i++)
              {
                   Log.i("test", "i value " + i);
                while (true)
                {
  
                  l1 += 16L;
                  l3 = l1 - l3;
                  if (l3 &lt; 0L)
                    break;
                  try
                  {
                      Log.i("inside","inside the thread");
                    Thread.sleep(l3);
                  }
                  catch (Exception localException)
                  {
  
                  }
                }
  
                Painter.this.onPaint(l3, false);
                break;
                }         
  
  
        }
      }).start();
  }
  </code></pre>