Work objects

A work object is a type of asynchronous bean used by application components to run code in parallel or in a different J2EE 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, see the Interface Work in the Javadoc.

A component wanting to run work in parallel, or in a different J2EE context, locates a work manager in 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 2 Developer Kit threads because they are not managed threads. Plus, these threads are not affiliated with the J2EE environment, which makes them useless inside an application server. In addition, these threads have no J2EE 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 Tasks


Developing work objects to run code in parallel

 

See Also


Example: Work object
Reference: Generated API documentation