Creates an ExecutorService with a specified bounded queue capacity that favors reusing
previously constructed threads, when they are available, over creating new threads. When a
task is submitted, if no existing thread is available, a new thread will be created and added
to the pool. If there is an existing idle thread available, the task will be handed to that
thread to execute. If the specified maximum thread limit is reached, subsequent tasks will be
queued and will execute as threads become available. If the maximum queue capacity is
reached, subsequent tasks will be rejected.
Threads that have not been used for sixty seconds are terminated and removed from the pool.
Thus, a pool that remains idle for long enough will not consume any resources.
By reusing threads when possible, this executor optimizes for reduced memory and thread
resource overhead at the expense of execution time.
If you need an executor with faster execution time where increased memory and thread resource
overhead is acceptable, consider using
#newBoundedFastThreadPool.