users@concurrency-ee-spec.java.net

[jsr236-spec users] Re: Some more feedback on PR

From: Anthony Lai <anthony.lai_at_oracle.com>
Date: Mon, 11 Feb 2013 13:19:18 -0800

Hi Arun,

Please see inlined

On 2/10/13 9:59 AM, Arun Gupta wrote:
> Hi Anthony,
>
> Here is some more feedback on PR:
>
> - In this code:
>
> @Resource(name = "concurrent/myFactory")
> ManagedThreadFactory factory;
> factory.newThread(new MyTask(5));
>
> newThread returns a Thread instead of ManageableThread. Shouldn't it
> return the later ?
It should return a Thread that also implements the ManagableThread
interface.

The caller of newThread does not need to know that the Thread implements
the ManageableThread interface. Only the tasks implementations need to
be aware of that and use its isShutdown() method to find out whether the
ManagedThreadFactory is being shut down.
>
> - Shouldn't ManageableThread inherit from java.lang.Thread ?
It could. But we chose to use an interface to allow more flexibility for
the implementors of ManagedThreadFactory in the implementation of their
Thread objects.
>
> - How are ManageableThreadFactory and ManagedExecutorService use cases
> different ? I can create bunch of threads from the former and create
> my own thread pool or executor service.
If you just want to submit some tasks to be processed asynchronously on
some threads provided by the Java EE product provider, and not
interested in managing the threads, ManagedExecutorService would be more
convenient.
>
> - IMHO ManagedThread is a better name than ManageableThread.
I am ok with that, but lets see if we get more votes for this.
>
> - There is a default ManagedThreadFactory. Should it be in the
> concurrent namespace, i.e.
>
> java:comp/concurrent/DefaultManagedThreadFactory
>
>
> instead of
>
>
> java:comp/DefaultManagedThreadFactory Concurrency Utilities for Java
> EE Concurrency Utilities for Java EE
>
We are following the convention of other default objects in the platform
specs, where the default objects are put in "java:comp/Default... "
> - Will the code:
>
> @Resource
> ManagedThreadFactory factory;
>
> be equivalent to:
>
> @Resource(lookup="DefaultManagedThreadFactory")
> ManagedThreadFactory factory;
You should be getting back the same default configured object in either
case.

Thanks
Anthony
>
> Thanks,
> Arun
> --
> http://twitter.com/arungupta
> http://blogs.oracle.com/arungupta