title: When and why would one use a group of Executor
body: <p>I have been reading about Executor in Android documentations. If I understood it correctly, it is used for multiple thread management and it does some of the work for you like spawning new threads when needed. Or you may choose to manage stuff yourself.</p>
  
  <p>In the example below, a group of executors are used instead of one. So it is something like a pool of pool of threads (?).</p>
  
  <pre><code>/**
  * Global executor pools for the whole application.
  *
  * Grouping tasks like this avoids the effects of task starvation (e.g. disk 
  reads don't wait behind
  * webservice requests).
  */
  @Singleton
  open class AppExecutors(
  private val diskIO: Executor,
  private val networkIO: Executor,
  private val mainThread: Executor
  ) {
  
  @Inject
  constructor() : this(
      Executors.newSingleThreadExecutor(),
      Executors.newFixedThreadPool(3),
      MainThreadExecutor()
  )
  
  fun diskIO(): Executor {
      return diskIO
  }
  
  fun networkIO(): Executor {
      return networkIO
  }
  
  fun mainThread(): Executor {
      return mainThread
  }
  
  private class MainThreadExecutor : Executor {
      private val mainThreadHandler = Handler(Looper.getMainLooper())
      override fun execute(command: Runnable) {
          mainThreadHandler.post(command)
      }
  }
  }
  </code></pre>
  
  <p>Why would one choose to use a group of executors? What do you achieve with it which you can't with just one executor?</p>