title: onDestroy from activity not executing right after Activity.finish()
body: <p>So here is the scenario where my doubt dwells: <strong>i have a Stack object of Activity in my Application class that will hold reference to all Activities that are currently alive in my App. All activity pushes itself into the Stack at its onCreate(), and pops itself at onDestroy().</strong></p>
  
  <pre><code>@Override
  protected void onCreate(Bundle savedInstanceState) {
      super.onCreate(savedInstanceState);
      MyApplicationClass.stackOfActivity.add(this);
  }
  
  @Override
  protected void onDestroy() {
      super.onDestroy();
      MyApplicationClass.stackOfActivity.pop();
  }
  </code></pre>
  
  <p>At MyApplicationClass (that is the class that extends Application) i created a method to finish the activities that are on the top of the Stack.</p>
  
  <pre><code>static public void popActivitiesFromStack(int  amountOfActivitiesToBePopedOut){
      if(stackOfActivity.size() &gt;= amountOfActivitiesToBePopedOut){
          for(int i = 0; i &lt; amountOfActivitiesToBePopedOut; i++){
              stackOfActivity.peek().finish();
          }
      }
  }
  </code></pre>
  
  <p><strong>The problem is that all iterations from the FOR from "popActivitiesFromStack" are executed before any OnDestroy() is executed</strong>, and with that no activity is poped out while the FOR is executed, and every finish() call called in the FOR goes to the same activity.</p>
  
  <p>So my question is, <strong>why in this scenario the onDestroy() is not being executed right after the finish()?</strong></p>