[concurrency-interest] scheduledthreadpoolexecutor threadsafe?

Peter Veentjer - Anchor Men p.veentjer at anchormen.nl
Tue Nov 29 08:39:57 EST 2005

I have a question about the thread safety of the


 private void delayedExecute(Runnable command) {
        if (isShutdown()) {
        // Prestart a thread if necessary. We cannot prestart it
        // running the task because the task (probably) shouldn't be
        // run yet, so thread will just idle until delay elapses.
        if (getPoolSize() < getCorePoolSize())

It could happen that a command is added to the Queue altough the
ExecutorService has just been shutdown. This task will never be
executed. Shouldn`t it be better if the ScheduledThreadPoolExecutor
received a Lock from the ThreadPoolExecutor to make this an atomic

The reason I`m asking this question is that I`m also extending to
ThreadPoolExecutor to getter better control on timout behaviour of the
offering of tasks.

Met vriendelijke groet,

Peter Veentjer
Anchor Men Interactive Solutions - duidelijk in zakelijke

Praediniussingel 41
9711 AE Groningen

T: 050-3115222
F: 050-5891696
E: p.veentjer at anchormen.nl
I : www.anchormen.nl

More information about the Concurrency-interest mailing list