title: android 4 - Graphics with more than one thread
body: <p>I have a skelton of a drawing program, using one thread :</p>
  
  <pre><code>    @Override
  public void surfaceCreated( SurfaceHolder holder) {
      pajeuThread = new PageThread( holder);
      pajeuThread.setRunning(true);
      Log.v(TAG, "surfaceCreated"  );
      pajeuThread.start();
  } // end method surfaceCreated
  </code></pre>
  
  <p>Then I write "Hello World" near the center of the page, and I also write a number incremented by 30 down the left side of the page like this :</p>
  
  <pre><code>public void dessineArbre( Canvas canvasse ) {
      compteur += 30;
      if ( compteur &gt; 500 ) compteur = 30;
      screenWidth = getWidth();
      screenHeight = getHeight();
      Log.v(TAG, "dessineArbre"  );
      pagePaint.setColor( Color.WHITE);
      canvasse.drawRect(0, 0, screenWidth, screenHeight, pagePaint);
      pagePaint.setColor( Color.GREEN);
      canvasse.drawText( "Hello World", 200, 200, pagePaint);
      canvasse.drawText(Integer.toString( compteur ), 10, compteur, pagePaint);
  } // end method dessineArbre
  </code></pre>
  
  <p>I would like the numbers drawn using a second thread.</p>
  
  <p>The Thread is handled by an inner class this way:</p>
  
  <pre><code>        private class PageThread extends Thread {
      private SurfaceHolder surfaceHoldere;
      private boolean threadIsRunning = true;
  
      public PageThread( SurfaceHolder holdere){
          surfaceHoldere = holdere;
          setName( "page thread");
      } // end constructor
  
      public void setRunning( boolean runninge)   {
          threadIsRunning = runninge;
      } // end setRunning
  
      @Override
      public void run() {
          Canvas canvasvas = null;
  
          while( threadIsRunning ) {
              try {
                  canvasvas = surfaceHoldere.lockCanvas(null);
  
                  synchronized( surfaceHoldere) {
                      Log.v(TAG, "PageThread try synchronized"  );
                      dessineArbre( canvasvas);
                  }// end synchronized
              } // end try
              finally {
                  if( canvasvas != null)
                      Log.v(TAG, "Pagethread finally"  );
                      surfaceHoldere.unlockCanvasAndPost(canvasvas);
              } // end finally
          } // end while
      } // end method run
  } // end class Pagethread
  </code></pre>
  
  <p>How could I create another object of this class Pagethread?</p>