title: my UI thread was not sleeping properly
body: <p>i'm making a 15 puzzle (http://en.wikipedia.org/wiki/Fifteen_puzzle) game, and i have an activity for user to select the background image, and then i pass that image to a new activity in order to scale and crop it.</p>
  
  <p>Now i want to show the solution to the user first for 3 secs then it would shuffle, i'm using code like this:</p>
  
  <pre><code>@Override
  public void onCreate(Bundle savedInstanceState) {
      super.onCreate(savedInstanceState);
      setContentView(R.layout.main);
  
      //...skip the code that gets the image and scales it 
  
      start();
  }
  </code></pre>
  
  <p>then in my start() funcion:</p>
  
  <pre><code>public void start() {
  
      //the createPuzzle function would create all the Views(tiles)
      //and add them to the root LinearLayout using addView() function
      createPuzzle(game.getBoardConfig(), dimension);
  
      //i was trying to sleep here
  
      shuffle();
  }
  </code></pre>
  
  <p>i used:</p>
  
  <pre><code>try {
      Thread.sleep(3000);
  } catch (InterruptedException e) {}
  </code></pre>
  
  <p>or:</p>
  
  <pre><code>SystemClock.sleep(3000);
  </code></pre>
  
  <p>but neither of them worked properly, they all paused the the thread right after i selected the image and when it was paused i can't see the new activity and the tiles i created. When the thread resumes, it was already showing the shuffled puzzle.</p>
  
  <p>I've been looking at the documentation for quite a while but still can't figure out what's wrong with my code, thanks for helping!</p>