Java Reference
In-Depth Information
Additionally, as mentioned earlier, we will stop the thread for 5 seconds so that we can
observe the execution later [4] .
We've got our building blocks in place. Now, it is time to combine them into a working
example. We can revisit our PendingSeats class from the beginning of this chapter, as
shown in the following code:
package com.packtpub.wflydevelopment.chapter12.external;
@Singleton
@Startup
public class PendingSeats {
private final Queue<Long> seats =
new ConcurrentLinkedQueue<
>();
@Resource
private ManagedExecutorService executorService; // [1]
@Inject // [2]
private Instance<GenerateSeatRequestsFromDatabase>
databaseCollector;
@Inject
private Instance<GenerateSeatRequestFromArtificial>
artificalCollector;
@Inject
private Logger logger;
@PostConstruct
private void setUp() {
try {
List<Future<List<Integer>>> futures =
executorService.invokeAll(Arrays.asList(
databaseCollector.get(), artificalCollector.get()
)); // [3]
Search WWH ::




Custom Search