[concurrency-interest] SingleThreadExecutor

Doug Lea dl@cs.oswego.edu
Sat, 24 Jan 2004 13:12:02 -0500


> is there a reason why Executors#singleThreadExecutor is created with
> corePoolSize=1 and not =0 ? I use worker queues a lot that have to
> work serialized but are often idle and I prefer to not have the thread
> lying around.

The thread is only created upon demand (i.e., not until first task is
submitted), but using the singleThreadExecutor factory, will never
time out, die, and be replaced if idle for long periods. If you want
to do this, you can use one of the ThreadPoolExecutor concstructors.
But for the simple case, we keep things simple; avoiding here the need
for someone to pick a keep-alive time.

-Doug