File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Threads and Synchronization and the fly likes Using singleton TaskExecutor and CompletionService Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of OCA/OCP Java SE 7 Programmer I & II Study Guide this week in the OCPJP forum!
JavaRanch » Java Forums » Java » Threads and Synchronization
Bookmark "Using singleton TaskExecutor and CompletionService" Watch "Using singleton TaskExecutor and CompletionService" New topic

Using singleton TaskExecutor and CompletionService

Zhui Shen Ge

Joined: Nov 22, 2009
Posts: 5
Requirement: JMS listener to spawn multiple concurrent web service requests. Each listener thread (the main thread) will wait max of 30 seconds. A maximum number of 5 child threads might be spawned from the main thread.

Is it safe to use a singleton TaskExecutor (I intend to use Spring's ThreadPoolTaskExecutor), and creating new instances of ExecutorCompletionService in the main thread?
Consider Paul's rocket mass heater.
subject: Using singleton TaskExecutor and CompletionService