title: Call the invalidate method from a thread
body: <p>I am looking for a way to call the invalidate method from a thread. Basically what i want to do is to call this <code>onDraw</code> method from the <code>DrawThread</code>.</p>
  
  <pre><code>protected void onDraw(Canvas canvas) {
      // Drawing commands go here
  
       canvas.drawArc(oval, strt, arc, true, cPaint);
       while(i&lt;90)
       {
       canvas.drawText(z,300,300, tPaint);
  
       break;
       }
  
  class DrawThread extends Thread
  {
  GameView a;
  Canvas canvas;
  DrawThread(GameView a)
  {
      this.a=a;
      start();
  }
  
  public void run()
  {
      a.flag2=true;
      while(a.flag2)
      {   
          try
          {
              sleep(200);
          }
          catch(Exception e)
          {
          }
  
      if(!a.flag1)
      {
          a.x+=10;
  
          if(!a.flag3)
          {
              a.strt-=15;
              a.arc+=15;
          }   
          else
          {
              a.strt+=15;
              a.arc-=15;
          }
  
      }
  
      if(a.flag1)
      {
          a.x-=10;
          if(!a.flag3)
              a.arc+=15;
          if(a.flag3)
              a.arc-=15;
      }   
  
      if(a.x==600)
      {
          a.y+=60;
          a.flag1=true;
          a.strt=180;
          a.arc=315;  
      }
  
      if(a.x==30)
      {
          a.y+=60;
          a.flag1=false;
          a.strt=45;
          a.arc=315;
  
      }
      if(a.y&gt;=600)
      {
          a.y=60;
      }
  
      if(a.strt==0 || a.arc==360)
      {
          a.flag3=true;
      }
  
      if(a.strt==45 || a.arc==315)
      {
          a.flag3=false;
      }
      if(a.n1==a.x&amp;&amp;a.n2==a.y)
      {
          a.i+=1;
          a.n1 = Math.random()*10;
          a.n2 = Math.random()*60;
      }
      a.invalidate();
      }
  }
  }
  </code></pre>