[concurrency-interest] BackPort: Threads not under control

Wed May 24 11:07:14 EDT 2006

Hi all,

We are using the Concurrent package (backport) in a J2ee application
which spans several threads to connect with various other sources for
information. I was skeptical to use this package on a J2ee application
due to the popular notion that custom multithreading is not recommended
on J2ee apps. Some people convinced me that this package has more APIs
to control the Threads created. 

Now coming to the real problem, below is the block of code I use to
start the various tasks and control them...

                ExecutorService service =
                List futures = service.invokeAll(tasks, 20,
                Iterator futuresIter = futures.iterator();
                while (futuresIter.hasNext()) {
                    Future future = (Future) futuresIter.next();
                    try {
                          searchResults = future.get();
                    } catch(CancellationException ce) {
                        log.warn("Task timed out. Exception Message: "
+ ce);
                    } catch(Exception e) {
                        log.warn("Exception occurred for a task.
Exception Message: " + e);
            System.out.println("SHUTDOWN ? " + service.isShutdown());

The 'tasks' that is called in the 'service.invoke()' are a list of
Callable implementations. When a Future task is timedout, as specified
in the invoke() method, control comes back to the exception but the
actual task still executes until it is terminated. The last stmt
(System.out) shows 'true', eventhough the task keeps executing until it
is dead. From the API declaration I believe the service tries to call
interrupt on this task but is it true that it cannot guarantee that the
task will stop and that shutdown will not always cause the task to stop
? Please advice. Also let me know if I am missing something... Really
appreciate your help...


More information about the Concurrency-interest mailing list