title: Count integer with Thread in Activity and update Canvas in View
body: <p>I'm developing my first android game without xml files for layouts in eclipse. This is calling MyGameView.class(extends View) from MyGameActivity.class(extends View implements OnTouchListener)</p>
  
  <pre><code> MyGameView myView;
   myView = new MyGameView(this);
   myView.setOnTouchListener(this);
   setContentView(myView);
  </code></pre>
  
  <p>Everytime, I touch (MotionEvent.ACTION_DOWN), I update the Canvas in MyGameView.class with the following code. This is the code I use to update MyGameView.class from MyGameActivity.class.</p>
  
  <pre><code> myView.invalidate();
  </code></pre>
  
  <p>Yes it works!But I got a serious problem now.I need to move Canvas in MyGameView.class by every 0.3 second.I use Thread to update but it forced stop!!!! I tried again and again and again! I failed!</p>
  
  <pre><code> public void runtime() {
   i = 0;
   Thread timer = new Thread(new Runnable() {
  
      @Override
      public void run() {
          while (i&lt;1500) {
              try {
                   Thread.sleep(300);
              }
              catch (InterruptedException e) {
                   e.printStackTrace();
              }
              finally {
                   if (right) {
                       i++;
                       //This is static int a from MyGameView.            
                       MyGameView.a += 2;
                       myView.invalidate();
                   }
                   else {
                       i = 1500;
                   }
               }
         }
    }
  });
  timer.start();
  </code></pre>
  
  <p>}</p>
  
  <p>Updating Static int or boolean to MyGameView.class from MyGameActivity.class with myView.invaldate(); is working. But I can't control it with Thread! Is there something wrong with my Thread running code?</p>
  
  <p>It's probably up to Thread because I can move +2 along X-axis to right everytime I press (MotionEvent.ACTION_DOWN).</p>
  
  <pre><code> //I can Move with this code but not with Thread!
   case MotionEvent.ACTION_DOWN:
        MyGameView.a += 2;
        myView.invalidate();
   break;
  </code></pre>
  
  <p>With Thread, it stops! Please give me a solution for this! In other words, I need to count with time without error and update canvas on every count!</p>