• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

In pool, how to judge that all tasks are done?

 
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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?
 
(instanceof Sidekick)
Posts: 8791
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
Ranch Hand
Posts: 1646
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic