A straightforward way to invoke asynchronous behavior is to annotate an EJB business method, or the EJB class, with @Asynchronous. Invocations to these methods immediately return, optionally with a Future response type. They are executed in a separate, container-managed thread. This usage works well for simple scenarios but is limited to EJBs:
import javax.ejb.Asynchronous; @Asynchronous @Stateless public class Calculator { public void calculatePi(long decimalPlaces) { // this may run for a long time } }