Java Reference
In-Depth Information
ReportGeneratorTask());
String result =
monitor.get();
Managed scheduled executor service: The ManagedScheduledEx-
ecutorService interface extends the ManagedExecutorService and
java.util.concurrent.ScheduledExecutorService interfaces in
order to execute a task at a specific time.
• Instances of this interface are defined in the same way as that of the
ManagedExecutorService interface. The following code demon-
strates how to execute a task ten seconds after its submission:
Future<String> monitor =
reportGenerator
.schedule(new
ReportGeneratorTask(),
10,TimeUnit.SECONDS);
Managed thread factory: The ManagedThreadFactory interface
providesmethodtocreatemanagedthreadinstancesinacontainer.Thetask
must implement the java.lang.Runnable interface. The following code
demonstrates how to create and run a container-managed thread.
Thread myThread =
threadFactory.newThread(new
ReportManagedThread());
myThread.start();
Context service: This interface allows the creation of contextual objects
without using ManagedExecutorService or ManagedScheduledEx-
ecutorService interfaces, as we did in the previous cases, with the aim
of allowing the extension of the capabilities of a Java EE platform for con-
currency. Concretely, with this interface, you can create a workflow system
or use customized Java SE platform ExecutorService implementations
within a container. For example, if you desire to use the pool management
mechanism provided by the class
java.util.concurrent.ThreadPoolExecutor of Java SE to manage
Search WWH ::




Custom Search