+

Search Tips   |   Advanced Search

Work objects

A work object is a type of asynchronous bean used by application components to run code in parallel or in a different JEE context.

A work object implements the com.ibm.websphere.asynchbeans.Work interface. A work object is essentially a java.lang.Runnable object that is serializable and provides additional methods. For details, refer to the Interface Work in the generated API documentation.

A component wanting to run work in parallel, or in a different Java EE context, locates a work manager in Java™ Naming and Directory Interface (JNDI), then calls the WorkManager.startWork() method using the work object as a parameter.

The startWork() method returns a work item object. This object is a handle that provides a link from the component to the now running work object. The work item object is typically used when the component needs to wait for one or more of its running work objects to complete. The WorkManager.join() method takes an array list of work items that the component wants to wait on, and a flag indicating whether the component will wait for all or one of the work objects to complete. A timeout can be specified, which prevents the component from waiting indefinitely.

The application does not create Java SE Development Kit 6 (JDK 6) threads because they are not managed threads. Plus, these threads are not affiliated with the Java EE environment, which makes them useless inside an application server. In addition, these threads have no Java EE context (for example, a java:comp) and are not authenticated when they fire. Work object threads are fully supported by the application server and have the same properties as other asynchronous beans.


Related concepts

  • Additional APIs


    Related tasks

  • Develop work objects to run code in parallel

  • Example: Create work objects Concept topic