geronimo-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From David Jencks <david_jen...@yahoo.com>
Subject Re: GBeans threading best practices
Date Wed, 03 Aug 2005 15:57:15 GMT
It's OK, but as a design principle I strongly recommend you use a  
separate thread pool.  We have a couple already and there are plans for  
a good one on the way :-)

The simplest is the DefaultThreadPool or  
org.apache.geronimo.pool.ThreadPool class.  An example of using from a  
gbean is the timer service in the timer module.  A gbean configuration  
for it is in the system-database-plan.xml and looks like this:

     <gbean name="JDBCTransactionalThreadPooledTimer"  
class="org.apache.geronimo.timer.jdbc.JDBCStoreThreadPooledTransactional 
Timer">
         <attribute name="repeatCount">5</attribute>
         <reference  
name="TransactionContextManager"><moduleType>J2EEModule</ 
moduleType><module>org/apache/geronimo/Server</ 
module><name>TransactionContextManager</name></reference>
         <reference  
name="ManagedConnectionFactoryWrapper"><moduleType>JCAResource</ 
moduleType><name>SystemDatasource</name></reference>
         <reference  
name="ThreadPool"><moduleType>J2EEModule</moduleType><module>org/ 
apache/geronimo/Server</module><name>DefaultThreadPool</name></ 
reference>
         <!--TODO remove moduleType when gbeans get the moduleType of  
the plan they are in -->
         <reference  
name="DerbySystem"><moduleType>J2EEModule</ 
moduleType><name>DerbySystem</name></reference>
     </gbean>


Note the reference to the thread pool.

thanks
david jencks

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?
>
> Geronimo won't know about them and it's up to the GBean to shut them
> down in doStop().
>


Mime
View raw message