[concurrency-interest] scheduledthreadpoolexecutor threadsafe?

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

 Hmm.. maybe I know the answer to my own question. The
ThreadPoolExecutor will execute all remaining tasks if it is shutdown.
So all queued tasks will be processed (unless shutdownNow is called).

-----Oorspronkelijk bericht-----
Van: concurrency-interest-bounces at cs.oswego.edu
[mailto:concurrency-interest-bounces at cs.oswego.edu] Namens Peter
Veentjer - Anchor Men
Verzonden: dinsdag 29 november 2005 14:40
Aan: concurrency-interest at altair.cs.oswego.edu
Onderwerp: [concurrency-interest] scheduledthreadpoolexecutor

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

Concurrency-interest mailing list
Concurrency-interest at altair.cs.oswego.edu

More information about the Concurrency-interest mailing list