ScheduledThreadPoolExecutor and corePoolSize 0?
I'd like to have a ScheduledThreadPoolExecutor which also stops the last thread if there is no work to do, and creates (and keeps threads alive for some time) if there are new tasks. But once there is no more work to do, it should again discard all threads. I naivly created it as new ScheduledThreadPoolExecutor(0) but as a consequence, no thread is ever created, nor any scheduled task is ever executed. Can anybody tell me if I can achieve my goal without writing my own wrapper around the ScheduledThreadpoolExecutor ? Thanks in advance! Alex V. Actually you can do it, but its non-obvious: