[Logo]
Forums Register Login
the end of thread
How could I know all threads arecompleted and the process could go on the next step?

Thanks,

Steve
Put all the threads in thread group.
In a while(true)loop continues check for threadgroup.activeCount()==0.
 

Originally posted by Jignesh Patel:
Put all the threads in thread group.
In a while(true)loop continues check for threadgroup.activeCount()==0.



The activeCount() method is documented as being approximate, so it probably isn't a good one to use here. Instead, keep track of all the threads that you've fired off, then join() them all. Note that you can join() them in any order; you don't have to join() them in the same order that they finish.
JDK 5 has some new helpers to rendezvous multiple threads. Look at CountdownLatch for example. CyclicBarrier also looks interesting. Maybe I'll have to make up a requirement to let me try it.
Let's go to the waterfront with this tiny ad:
ScroogeXHTML 7.1 - RTF to HTML5 / XHTML converter
https://coderanch.com/t/690611/ScroogeXHTML-RTF-HTML-XHTML-converter


This thread has been viewed 650 times.

All times above are in ranch (not your local) time.
The current ranch time is
Feb 20, 2018 14:28:17.