File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Threads and Synchronization and the fly likes the end of thread Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Java » Threads and Synchronization
Bookmark "the end of thread" Watch "the end of thread" New topic
Author

the end of thread

Steve Jiang
Ranch Hand

Joined: May 17, 2004
Posts: 107
How could I know all threads arecompleted and the process could go on the next step?

Thanks,

Steve
Jignesh Patel
Ranch Hand

Joined: Nov 03, 2001
Posts: 626

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

Joined: Oct 30, 2001
Posts: 1970
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.


Betty Rubble? Well, I would go with Betty... but I'd be thinking of Wilma.
Stan James
(instanceof Sidekick)
Ranch Hand

Joined: Jan 29, 2003
Posts: 8791
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.


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
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: the end of thread
 
Similar Threads
SWINGS Over Use of Vectors
JApplet can't start
Commit Suicide Not Incest
swing.properties list
Why did the chicken cross the road?