jsr236-experts@concurrency-ee-spec.java.net

[jsr236-experts] Re: Thread Shutdown

From: Anthony Lai <anthony.lai_at_oracle.com>
Date: Mon, 30 Jul 2012 15:28:30 -0700

Hi David,

Please see inlined:

On 7/23/12 8:26 PM, David M. Lloyd wrote:
> Sorry, fixed subject line...
>
> On 07/23/2012 10:24 PM, David M. Lloyd wrote:
>> According to the Javadoc at [1], support for managed thread factories is
>> intended. I am wondering if any particular shutdown mechanism has been
>> specified? How will the container tear down threads associated with a
>> given component?
The spec does not specify how ManagedThreadFactory instances are shut
down. I would imagine that the container would have some method in its
ManagedThreadFactory implementation class that would be called to
shutdown the ManagedThreadFactory instance. Each of those instance would
maintain a list of its threads and each of these threads would be
interrupted during shutdown.
>>
>>
>> I would like to suggest that we specify a thread base class or interface
>> for managed threads, which includes an isShutdown() method which would
>> return a flag which is set when the thread is requested to terminate.
>> The thread should also be interrupted at this time.
Could you explain how this new interface method will be used during
shutdown? Thanks.
>>
>> I would also suggest that threads started after component shutdown was
>> initiated should be allowed to run, but they should start with an
>> interrupted status and their shutdown flag set.
Would the intention for this be to allow creation of new threads for
various resource cleanup during component shutdown? If the
ManagedThreadFactory belongs to the same component, would this mean we
are requiring ManagedThreadFactory to be shutdown last during a
component shutdown?

Regards
Anthony
>>
>> [1]
>> http://concurrency-ee-spec.java.net/javadoc/index.html?javax/enterprise/concurrent/ManagedThreadFactory.html
>>
>>
>
>