title: SurfaceView onDraw skips drawing
body: <p>My surfaceview onDraw method sometimes skips drawing some bitmaps on the screen and once it skips it never draws the particular bitmaps again.
  My code</p>
  
  <pre><code>public class Board extends SurfaceView implements SurfaceHolder.Callback{
   //varaibles declared here
  public Board(){
      //initaializations here
      getHolder().addCallback(this);
   }
  //my onDraw method
  protected void onDraw(Canvas canvas){
     for(int u = 0;u&lt;6; u++){
        ai.get(u).draw(canvas);//each of these objects draws something on the screen.
        human.get(u).draw(canvas);
     }
     postInvalidate();
   }
  
  public void surfaceCreated(SurfaceHolder holder){
  gameLoop = new GameLoop(this);
  gameLoop.start();
  }
  </code></pre>
  
  <p>The onDraw() method is called every 100milliseconds in a thread that runs the game loop.</p>
  
  <pre><code>public class GameLoop extends Thread{
       Board board;
       private final int DELAY = 100;
       public GameLoop(Board board){
        this.board=board;
       }
  
     protected void run(){
       long beforeTime,timediff,sleep;
       beforeTime = System.currentTimeMillis();
       while(running)
       {
         Canvas c = null;
         try{
             c=board.getHolder.lockCanvas();
             synchronized(board.getHolder()){
                board.onDraw(c);
            }finally{
             if(c!=null)
               board.getHolder.unlockCanvas(c);
            }
        timeDiff = System.currentTimeMillis - beforeTime;
        sleep = DELAY - timeDiff;
        if(sleep&lt;0)
          sleep = 10;
        try{
           Thread.sleep(sleep);
        }catch(InterruptedException e){}
        beforeTime = System.currentTimeMillis();
     }
  }
  </code></pre>
  
  <p>So this skips happen like this: sometimes(in the onDraw() method) when u=0 does not draw or u = 5, it could be u = any of the possible values and the rest draws and once it skips that values it keeps skipping it everytime the onDraw method is called. I hope I have been able to make it clear enough.
  I would appreciate help to resolve this problem. Thanks</p>