Work managers
A work manager provides threading for Java™ Platform, Enterprise Edition (Java EE) applications.
- Managed executors
- javax.enterprise.concurrent.ManagedExecutorService
- javax.enterprise.concurrent.ManagedScheduledExecutorService
- java.util.concurrent.ExecutorService
- java.util.concurrent.ScheduledExecutorService
- Thread factories
- javax.enterprise.concurrent.ManagedThreadFactory
- java.util.concurrent.ThreadFactory
- Thread context service
- javax.enterprise.concurrent.ContextService
- Asynchronous beans
- com.ibm.websphere.asynchbeans.WorkManager
- CommonJ work manager
- commonj.work.WorkManager
The work managers provide a programming model for the Java EE applications. For more information, see the Programming model section.

When you are writing a web or Enterprise JavaBeans (EJB) component that uses Concurrency Utilities for Java EE or asynchronous beans, the developer must include a resource environment reference in each component that needs access to a managed executor, thread factory, context service, or work manager. For more information on resource references, see the References topic. The component looks up a managed executor, thread factory, context service, or work manager that uses a logical name in the component, java: comp namespace, just as it looks up a data source, enterprise bean, or connection factory.
The deployer binds physical work managers to logical resource environment references (managed executors, thread factories, context services, or work managers) when the application is deployed.
For example, if a developer needs three thread pools to partition work between bronze, silver, and gold levels, the developer writes the component to pick a logical pool based on an attribute in the client application profile. The deployer has the flexibility to decide how to map this request for three thread pools. The deployer might decide to use a single thread pool on a small system. In this case, the deployer binds all three resource references to the same work manager instance (that is, the same JNDI name). A larger system might support three thread pools, so the deployer binds each resource reference to a different work manager. Work managers can be shared between multiple Java EE applications installed on the same server.
An application developer can use as many logical resource environments references as necessary. The deployer chooses whether to map one physical work manager or several to the logical managed executor, thread factory, context service, or work manager defined in the application.
All Java EE components that need to share asynchronous scope objects must use the same work manager. These scope objects have an affinity with a single work manager. An application that uses asynchronous scopes must verify that all of the components that use scope objects also use the same work manager.
When multiple work managers are defined, the underlying thread pools are created in a Java virtual machine (JVM) only if an application within that JVM looks up the work manager. For example, with 10 thread pools (work managers) defined, none are created until an application looks up these pools.
CommonJ Work Manager
The CommonJ work manager contains a subset of the asynchronous beans work manager methods. Although CommonJ work manager functions in a Java EE environment, the interface does not return a new instance for each JNDI naming lookup, since this specification is not included in the Java EE specification.
The CommonJ Work specification optional feature for work running remotely is not supported. Even if a unit of work implements the java.io.Serializable interface, the unit of work does not run remotely.
How to look up a managed executor
InitialContext ic = new InitialContext();
ManagedExecutorService executor = (ManagedExecutorService) ic.lookup("java:comp/env/concurrent/myExecutor");
Inheritance Java EE contexts
- Internationalization context
- When this option is selected and the internationalization service is enabled, and the internationalization context that exists on the scheduling thread is available on the target thread.
- Work area
- When this option is selected, the work area context for every work area partition that exists on the scheduling thread is available on the target thread.
- Application profile (deprecated)
- Application profile context is not supported and not available for most applications. For Java EE 1.3 applications, when this option is selected, the application profile service is enabled, and the application profile service property, 5.x compatibility mode, is selected. The application profile task that is associated with the scheduling thread is available on the target thread for Java EE 1.3 applications. For Java EE 1.4 or higher applications, the application profile task is a property of its associated unit of work, rather than a thread. This option has no effect on the behavior of the task in Java EE 1.4 or higher applications. The scheduled work that runs in a Java EE 1.4 application does not receive the profiling task of the scheduling thread.
- Security
- The task can be run as anonymous or as the client authenticated on the thread that created and submitted it. This behavior is useful because the task can do only what the caller can do. This action is more useful than a RUN_AS mechanism, for example, which prevents this kind of behavior. When you select the Security option, the JAAS subject that exists on the scheduling thread is available on the target thread. If not selected, the thread runs anonymously.
- Component metadata
- Component metadata is relevant only when the task is a simple Java object. If the task is a Java EE component, such as an enterprise bean, the component metadata is active.
The contexts that can be inherited depend on the work manager, which is used by the application that creates and submits the task. Using the administrative console, the administrator defines the sticky context policy of a work manager by selecting the services on which the work manager is to be made available.
Programming model
- Concurrency Utilities for Java EE. The Java EE specification standardizes this programming model, which includes Managed Executors, Managed Scheduled Executors and Managed Thread Factories, which inherit from the familiar Java SE java.util.concurrent API. It also includes the Context Service, which has no equivalent in the java.util.concurrent API.
- Asynchronous beans. The current asynchronous beans Work Manager, Event Source, asynchronous scopes, subsystem monitors, and Java EE Context interfaces are a part of the Asynchronous beans programming model.
- CommonJ Specification. The CommonJ programming model uses the WorkManager and TimerManager to manage threads and timers asynchronously in the Java EE environment.
For more information on managed executors, thread factories, context service, and work manager APIs, see the Javadoc.
Concurrency examples
Managed Executor | Asynchronous beans | CommonJ |
---|---|---|
|
|
|
Managed Executor | Asynchronous beans | CommonJ |
---|---|---|
|
|
|
Managed Executor | Asynchronous beans | CommonJ |
---|---|---|
|
|
|
Managed Scheduled Executor | Asynchronous beans | CommonJ |
---|---|---|
|
|
|
Managed Scheduled Executor | Asynchronous beans | CommonJ |
---|---|---|
|
|
|