Peter Taucher wrote:I think you need to shutdown the pool sometime. Try adding this code at the end of your main method:
That seems unnecessarily complex - shutdown() will already wait until all current tasks are completed, so I'd just call it directly.
The problem is, it sounds like Ravi wants to keep this pool around awhile to await future tasks, and sometimes all the threads get suspended somehow.
I can't seem to recreate the problem on my machine using the code shown. I'm running a Mac, so the different JVM internals may be why I can't recreate it.
When I do a thread dump, I get virtually the same results as Ravi - with the critical difference that all his threads say "(Suspended)", while mine do not. So the question is, what causes the threads to become suspended?
One thing to try is to run this in an
IDE, and set a break point on the suspend() method in the Thread class. If something in the system is calling suspend(), this should let you know what it is.
Anyone else got any ideas on what might cause the threads to become suspended?