[concurrency-interest] ThreadPoolExecutor not shutting down

Martin Buchholz martinrb at google.com
Sat Mar 20 15:21:02 EDT 2010


There's a pretty good chance that
ThreadPoolExecutor and ScheduledThreadPoolExecutor
from a recent JDK or Doug's CVS would
Just Work with an older JDK.

Try it - you'll have to compile them and prepend to
bootclasspath using  -Xbootclasspath/p:

Martin

On Sat, Mar 20, 2010 at 04:59, Dibyendu Majumdar
<concurrency-interest at majumdar.org.uk> wrote:
> David, Ben,
> The fact that the MAC OS X Tiger version of the concurrency library is so
> old did alarm me. But I suppose that unless Apple do something about it, we
> have to live with it. As far as I understand, the latest library is
> incompatible with Java 5 - am I correct?
>
> Regards
>
> Dibyendu
>
> On 19 March 2010 00:43, David Holmes <davidcholmes at aapt.net.au> wrote:
>>
>> In general a ThreadPoolExecutor must be explicitly shutdown. Your
>> application needs to manage the TPE lifecycle. In later JDK versions you can
>> use the idle timeout on core threads to let all threads terminate.
>>
>> A daemon thread factory will prevent the TPE from keeping the VM alive,
>> but at the risk of allowing submitted tasks to not be run or to be
>> terminated in the midst of execution - generally not a good thing.
>>
>> A shutdown hook is of little help here as the hooks will only run if the
>> VM has decided to shutdown due to no user-threads (which can't be the case
>> due to the TPE), or System.exit has been called, in which case there's no
>> need to explicitly shutdown the TPE (it's about to get obliterated by
>> process termination), unless you want to manage the unfinished tasks.
>>
>> HTH
>>
>> David Holmes
>>
>> -----Original Message-----
>> From: concurrency-interest-bounces at cs.oswego.edu
>> [mailto:concurrency-interest-bounces at cs.oswego.edu]On Behalf Of Ben Manes
>> Sent: Friday, 19 March 2010 10:35 AM
>> To: Dibyendu Majumdar; concurrency-interest at cs.oswego.edu
>> Subject: Re: [concurrency-interest] ThreadPoolExecutor not shutting down
>>
>> This sounds like you'd want to use daemon thread factory, use a shutdown
>> hook to stop the executor, or another approach to let the VM gracefully
>> exit.
>>
>> ________________________________
>> From: Dibyendu Majumdar <concurrency-interest at majumdar.org.uk>
>> To: concurrency-interest at cs.oswego.edu
>> Sent: Thu, March 18, 2010 3:05:34 PM
>> Subject: [concurrency-interest] ThreadPoolExecutor not shutting down
>>
>> I am running Java 1.5 on Mac OS X Tiger - and I think that the
>> ThreadPoolExecutor code is a very old version. The pool is not shutting
>> down; by running through the debugger I can see that all idle threads are
>> blocked on a queue, and the shutdown sequence does not interrupt idle
>> threads.
>> Is there any way I can run a more up-to-date version with Java 1.5?
>> Is there a known workaround to this issue?
>>
>> Many thanks
>>
>> Regards
>> Dibyendu
>>
>>
>>
>>
>
>
> _______________________________________________
> Concurrency-interest mailing list
> Concurrency-interest at cs.oswego.edu
> http://cs.oswego.edu/mailman/listinfo/concurrency-interest
>
>



More information about the Concurrency-interest mailing list