title: Thread.sleep within for loop causing issue with loop body
body: <p>So in the code posted below I have a for loop which iterates 10 times, the goal of the for loop is to create the same ImageView 10 times every .5 seconds. When I tested this, it added everything at the same time after 5 seconds (assuming because it goes through the loop and waits 500ms to go through it again, 500ms * 10 = 5 seconds).</p>
  
  <p>Thing is, why does it wait the 500ms 10 times in the loop THEN do the rest of everything in the for loop.</p>
  
  <p>I added a Log.i print message to see if that would get printed at the same time, and if there was something wrong with my thread or for loop, and the message was printed every 500ms. I don't understand why it does the Log.i message every 500ms but the rest of the code inside the loop is done after when it's in the same brackets and both before the Thread.sleep method.</p>
  
  <p>Thank you!
  Code:
  <strong>Main Code(The error is within the btnRoundsClick method)</strong></p>
  
  <pre><code>    Variables var = new Variables();
  EntityActions e = new EntityActions();
  
  @Override
  public void onCreate(Bundle savedInstanceState) {
      super.onCreate(savedInstanceState);
      requestWindowFeature(Window.FEATURE_NO_TITLE);
      final Window window = getWindow();
      window.setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,                WindowManager.LayoutParams.FLAG_FULLSCREEN);
      setContentView(R.layout.firstmap);
      FontTextView username = (FontTextView) findViewById(R.id.lblUsername);
      username.setText("NAME");
      RelativeLayout map1 = (RelativeLayout) findViewById(R.id.map1); 
      e.setMap(map1);
  }
  
  // On click of button, add enemies
  public void btnRoundsClick(View view) {
      ImageView firetower[] = new ImageView[10];
      for (int c = 0; c &lt; 10; c++) {
           try
                  {
                  firetower[c] = new ImageView(Start.this);
                    firetower[c].setImageResource(R.drawable.firetower);
                  e.setEnemy(firetower[c]);
                  e.setStartEnd(0, 0, 0, 198);
                  e.addEnemy();
                  e.followPath();
                  Log.i("There  is 1 ", "more ImageView");
                  Thread.sleep(500);
              } catch (Exception e)
              {
                  e.printStackTrace();
              }
      }
  }
  </code></pre>
  
  <p><strong>EntityActions class</strong>
      ImageView enemy;
      int startX, startY, endX, endY;
      RelativeLayout map;</p>
  
  <pre><code>public EntityActions() {
      startX = 0;
      endX = 0;
      startY = 0;
      endY = 0;
  }
  
  public void setEnemy(ImageView enem) {
      enemy = enem;
  }
  
  public void setMap(RelativeLayout m) {
      map = m;
  }
  
  public void addEnemy() {
      map.addView(enemy);
      enemy.getLayoutParams().height = 60;
      enemy.getLayoutParams().width = 60;
      RelativeLayout.LayoutParams head_params = (RelativeLayout.LayoutParams)enemy.getLayoutParams();
      head_params.setMargins(30, -20, 0, 0); //substitute parameters for left, top, right, bottom
      enemy.setLayoutParams(head_params);
  }
  
  public void setStartEnd(int xS, int xE, int yS, int yE) {
      startX = xS;
      endX = xE;
      startY = yS;
      endY = yE;
  }
  
  public void followPath() {
      TranslateAnimation animation = new TranslateAnimation(startX, endX, startY, endY);
      animation.setDuration(6000);
      animation.setFillAfter(true);
      ((View) enemy).startAnimation(animation);
  }
  </code></pre>
  
  <p>If I have missed anything or you have further questions, let me know.</p>