+

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

WebSphere Application Server supports the use of the Spring Framework WorkManagerTaskExecutor class to run work asynchronously.

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

Do not use other TaskExecutor classes provided with the Spring Framework, because they might start unmanaged threads.

We 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 application server, 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 managed by the application server. 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.

  • Configure work managers
  • Spring Documentation