I'm trying to calculate some metrics, once all the threads in the myclass are done, the job is done for the thread once i reach the timeout scenario, which i able to hit for every thread. Now in the main () method in the Group class how can i wait for all the myclass threads to complete ?
I dont want to use any sleep() scenario
Group Class
class myGroup {
public void run(int numThreads) {
executor = Executors.newFixedThreadPool(numThreads);
executor.submit(new myclass(threadNumber));
}
public static void main(String[] args) {
run(noOfthreads);
// Collect metrics once all the myclass threads are done.
}
}
myclass
class myclass implements Runnable {
try{
}
catch(SomeTimeoutException cte){
// Job Done for thread
}
}