title: Multiple simultaneous HTTP requests on Android
body: <p>So, I have the code below inside an AsyncTask and want to call 7 different asynchronous HTTP requests. All works well, all the 7 execute() methods start at the same time (give a take a few millis, which is great).</p>
  
  <p>Unfortunately, the time it takes with this method is aprox. 16 secs. If I exclude all executor stuff and call the HTTP download methods on the original worker Asynctask, it takes aprox. 9 secs. So, it actually takes less time in sequential order rather than concurrent. Any ideas why this is happening ? Maybe something on the server side ? Maybe because the executors were started on an Asynctask ? Thanks a lot !</p>
  
  <pre><code>            MyExecutor executor = new MyExecutor(7, 7, 40000, TimeUnit.MILLISECONDS, new LinkedBlockingQueue&lt;Runnable&gt;());
              executor.execute(new Runnable()
              {
                  @Override
                  public void run()
                  {
                      try {downloadSplashScreenJsonData();}
                      catch (Exception e)
                      {
                          Log.e(TAG, "Could not download splashscreen data.");
                          e.printStackTrace();
                      }
                  }
              });
              // after another 6 executor.execute() calls,
              executor.shutdown();
              executor.awaitTermination(40000, TimeUnit.MILLISECONDS); 
  
      class MyExecutor extends ThreadPoolExecutor
      {
  
  
      public MyExecutor(int corePoolSize, int maximumPoolSize,
              long keepAliveTime, TimeUnit unit,
              BlockingQueue&lt;Runnable&gt; workQueue) {
          super(corePoolSize, maximumPoolSize, keepAliveTime, unit, workQueue);
          prestartAllCoreThreads();
          // TODO Auto-generated constructor stub
  
      }
  
      @Override
      public void execute(Runnable command) {
          super.execute(command);
          Log.e(TAG, "execute()");
          Log.e(TAG, "no of thr: " + getActiveCount());
  
      }
  }
  </code></pre>