title: `AsyncExecutor` meant to execute one `AsyncTask` at a time sometimes executes two alongside each other
body: <h2><code>AsyncExecutor</code></h2>
  
  <p>I have an <a href="https://libgdx.badlogicgames.com/nightlies/docs/api/com/badlogic/gdx/utils/async/AsyncExecutor.html" rel="nofollow noreferrer"><code>AsyncExecutor</code></a> that is defined as following:</p>
  
  <pre><code>asyncExecutor = new AsyncExecutor(1);
  </code></pre>
  
  <p>The constructor for the <code>AsyncExecutor</code> is <code>AsyncExecutor(int maxConcurrent)</code>, whereas the <code>maxConcurrent</code> is how many <code>AsyncTask</code>s is allowed to run alongside each other at one point in time. If it’s set to one, it’s then supposed to run all <code>AsyncTask</code>s contained by it in the order they were added.</p>
  
  <h2><code>AsyncTask</code></h2>
  
  <p>I’m implementing the <code>AsyncTask</code> interface on a class I’ve created to handle a certain set of logic that needs be run one by one in the order they’re <code>submit</code>ted onto the <code>AsyncExecutor</code>—by calling the <code>submit</code> method on the <code>AsyncExecutor</code>:</p>
  
  <pre><code>private class Foo implements AsyncTask&lt;Object&gt;
  {
      // ...
  
      public Foo()
      {
          // Transfers variables over
      }
  
      @Override
      public Object call() throws Exception
      {
          System.out.println("Start");
  
          // Does some stuff here
  
          System.out.println("Stop");
  
          return null;
      }
  }
  </code></pre>
  
  <p>I then <code>submit</code> these <code>Foo</code>s onto the <code>asyncExecutor</code> every once in a while and require them to run in order from the time they were added. This is the case most of the time, but let’s have a look at the console output—every once in a while, this isn’t the case:</p>
  
  <blockquote>
    <p><code>...</code><br>
    <code>Start</code><br>
    <code>Stop</code><br>
    <code>Start</code><br>
    <code>Stop</code><br>
    <code>Start</code><br>
    <code>Start</code><br>
    <code>Stop</code><br>
    <code>Start</code><br>
    <code>Start</code><br>
    <code>Stop</code></p>
  </blockquote>
  
  <p>Is there something I’ve missed? This is clearly supposed to never have “Start” stated on two lines next to one another—nor “Stop” for that matter.</p>
  
  <p>Perhaps someone can point me in the right direction?</p>