title: How to get a smooth move?
body: <p>Hi I am not getting a smooth move, in my game train moves front and back it is nice, but train movement is not smooth(like not train move fixed speed and smooth). Please help............</p>
  
  <pre><code>public void run() {
  Canvas canvas = null;
  
  while (mRun) {
      long beginTimeMillis, timeTakenMillis, timeLeftMillis;
      canvas = mHolder.lockCanvas();
      if (canvas != null) {
           beginTimeMillis = System.currentTimeMillis();
          gp.doDraw(canvas);
          gp.animate();
          timeTakenMillis = System.currentTimeMillis() - beginTimeMillis;
          timeLeftMillis = (1000L / 30) - timeTakenMillis;
          Log.i("timeLeftMillis"+timeLeftMillis,"");
          mHolder.unlockCanvasAndPost(canvas);
          if (timeLeftMillis &lt; 5) { 
              timeLeftMillis = 5; 
  
          }
          try {
              TimeUnit.MILLISECONDS.sleep(timeLeftMillis);  
          } catch (InterruptedException ie) {
          }
      }
  
     }
   }
  </code></pre>
  
  <p>Edit: I don't know how to use the thread while getting a smooth move.</p>