Hello. Because no jdk5.0 installed, I'm using EDU.oswego.cs.dl.util.concurrent.PooledExecutor for thread pooling. I know using Thread.join() can let main thread wait until that thread dies, but in PooledExecutor, how to do the same thing?
Joined: Jan 29, 2003
Can you get access to the underlying queue of commands? You could maybe check to see if it's empty.
Or if you will be coding all the commands to be executed, you could make them increment a static (global) counter when they start, decrement when they end. Any time the counter is zero then all tasks are done. Make sure the task has a try-catch with the decrement code in a finally clause so it's as reliable as possible.
A good question is never answered. It is not a bolt to be tightened into place but a seed to be planted and to bear more seed toward the hope of greening the landscape of the idea. John Ciardi
Joined: Aug 07, 2003
You can construct the PooledExecutor with a pre-built Channel instead of letting it create its own. This would give you access to check if it's empty. Look at the source for PE to see what kind of Channel it creates by default, or pick your own implementation.