+

Search Tips   |   Advanced Search

Thread management and the Spring Framework


Use the information in the following sections to avoid potential problems with unmanaged threads.

 

Unmanaged threads

Do not use a scenario that can create unmanaged threads, for the following reasons:

The following scenarios are examples of Spring Framework scenarios to avoid:

 

Thread pooling

WAS supports the use of the Spring Framework WorkManagerTaskExecutor class to run work asynchronously.

The WorkManagerTaskExecutor class uses thread pools that are managed by the appserver, and delegates to a configured WorkManager instance. For information about configuring a work manager, see the related topics.

Do not use other TaskExecutor classes that are provided with the Spring Framework, because they might start unmanaged threads. You can use the JNDI name of the configured work manager as a workManagerName property to define a WorkManagerTaskExecutor instance in the Spring configuration file.

The following example uses the JNDI name of the DefaultWorkManager in the appserver, that is, wm/default:

<bean id="myTaskExecutor" 
  class="org.springframework.scheduling.commonj.WorkManagerTaskExecutor">
  <property name="workManagerName" value="wm/default" />
</bean>

 

Scheduling

Use the CommonJ WorkManager scheduling package in the Spring Framework to work with threads that are managed by the appserver. Avoid using other packages, such as the Quartz scheduler, or the Timer in the Java SE Development Kit (JDK), because they can start unmanaged threads.




 

Related concepts


Spring Framework

 

Related tasks


Set work managers

 

Related information


Spring Documentation