On Aug 3, 2005, at 9:34 AM, Dain Sundstrom wrote:

On Aug 3, 2005, at 8:13 AM, Miguel A Paraz wrote:



Hi,
I'm planning on writing my own GBeans to implement services.

Is it OK to start new Threads - using new Thread() directly, or
indirectly by using util.concurrent facilities which I see in the
code?



You can start threads directly, but it is preferrable to use a EDU.oswego.cs.dl.util.concurrent.Executor. The best practice is to have the Executor inject via constructor injection or setter injection. This allows a user of your service to have complete control the properties of the thread pool.


Let me be a bit more clear. I suggest you write your code to use the concurrent executor since it is common reusable api with many implementations. When it comes to deploying your service in Geronimo, the Geronimo ThreadPool class implements the Executor so you can just use that service with a Geronimo GBean reference.

-dain


Reply via email to