Link to home
Start Free TrialLog in
Avatar of acilonv
acilonvFlag for Romania

asked on

Blocking Java Thread Pool

Hello,

I'm looking for the simplest way to have in Java a pool of threads with the ability to specify the maximum number of threads, know at any given time how many threads are running and know when all the threads have finished running.

Thank you.
Avatar of miahi
miahi
Flag of Romania image

I think the ThreadPoolExecutor is what you need: http://java.sun.com/j2se/1.5.0/docs/api/java/util/concurrent/ThreadPoolExecutor.html

You can set the maximum number of threads, get the number of executing threads, and you can set a method to be invoked when a thread ends, where you can check if it is the last one.
Avatar of acilonv

ASKER

I tried using the ThreadPoolExecutor class but was unable to see how to check when the last threads.
How do you do that?
>but was unable to see how to check when the last threads

When the last threads do what?
Avatar of acilonv

ASKER

Oh, sorry. .... when it ends. How do I check when the last thread ends?
ASKER CERTIFIED SOLUTION
Avatar of miahi
miahi
Flag of Romania image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of acilonv

ASKER

no code provided