Java Reference
In-Depth Information
hung-task-threshold : This defines after how many milliseconds the server will
mark a thread as hung. If set to 0 , a thread will never be marked as hung (the
thread will have no execution time limit).
By using these configuration properties and creating additional executor services, the
server administrator can gain a fine control over the maximum load that the server can
handle at a given time. Be sure to take a closer look at them during an application's per-
formance tuning.
As for development, the default configuration suits us well, so it's time to dive into the
code with an example usage of the concurrency utilities!
Introducing threads to enterprise beans
When we were working with the batching framework, we contacted a REST endpoint,
which was mocking an external system in our sample. Now, we are going to add some
concurrency to it.
An external system may aggregate booking requests from several sources. If every request
takes a substantial amount of time, it could be a good idea to make all the requests simul-
taneously. Let's start with creating Callable , which will return a list of the seat IDs that
should be booked. This is shown in the following code snippet:
package com.packtpub.wflydevelopment.chapter12.external;
import java.util.concurrent.Callable;
import javax.enterprise.concurrent.ManagedTask;
import javax.enterprise.concurrent.ManagedTaskListener;
import javax.enterprise.inject.Instance;
public class GenerateSeatRequestFromArtificial implements
Callable<List<Integer>>, ManagedTask [1] {
private Logger logger;
private Instance<TaskListener> taskListener; [2]
Search WWH ::

Custom Search