title: Nested / normal for loops in AsyncTask
body: <p>I've been testing some asynctasks in android.</p>
  
  <p>But I found some illogical outcomes on these codes:</p>
  
  <pre><code>int a1Sum = 0;
  int a2Sum = 0;
  
  long a1Time = 0;
  long a2Time = 0;
  
  private class Async1 extends AsyncTask&lt;Void, Void, String&gt; {
      protected void onPreExecute() {
          a1Time = System.currentTimeMillis();
      }
  
      protected String doInBackground(Void... arg0) {
          for (int i = 0; i &lt; 10000; i++) {
              publishProgress();
          }
          return "You are at PostExecute";
      }
  
      protected void onProgressUpdate(Void... arg0) {
          a1Sum++;
      }
  
      protected void onPostExecute(String result) {
          Log.d("A1 Time", String.valueOf(System.currentTimeMillis() - a1Time)); // records the executing time
          AsyncTask async2 = new Async2().execute();
      }
  }
  
  private class Async2 extends AsyncTask&lt;Void, Void, String&gt; {
      protected void onPreExecute() {
          a2Time = System.currentTimeMillis();
      }
  
      protected String doInBackground(Void... arg0) {
          for (int i = 0; i &lt; 10; i++) {
              for (int j = 0; j &lt; 10; j++) {
                  for (int k = 0; k &lt; 10; k++) {
                      for (int l = 0; l &lt; 10; l++) {
                          publishProgress();
                      }
                  }
              }
          }
          return "You are at PostExecute";
      }
  
      protected void onProgressUpdate(Void... arg0) {
          a2Sum++;
      }
  
      protected void onPostExecute(String result) {
          Log.d("A2 Time", String.valueOf(System.currentTimeMillis() - a2Time)); // records the executing time
      }
  }
  </code></pre>
  
  <p>those two asynctasks do the same jobs but here is the illogical part:</p>
  
  <p>as you see on the code, <code>a1Time</code> and <code>a2Time</code> records the executing time and here is the result of them:</p>
  
  <pre><code>D/A1 Time: 1025
  D/A2 Time: 768
  D/A1 Time: 1022
  D/A2 Time: 716
  D/A1 Time: 1017
  D/A2 Time: 729
  D/A1 Time: 1063
  D/A2 Time: 830
  D/A1 Time: 1059
  D/A2 Time: 784
  </code></pre>
  
  <p>My question is: What makes the <code>Async2</code> run faster?</p>