Granny's Programming Pearls
"inside of every large program is a small program struggling to get out"
JavaRanch.com/granny.jsp
The moose likes Threads and Synchronization and the fly likes Thread B has to start after completion of 5 instances of Thread A Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Threads and Synchronization
Bookmark "Thread B has to start after completion of 5 instances of Thread A" Watch "Thread B has to start after completion of 5 instances of Thread A" New topic
Author

Thread B has to start after completion of 5 instances of Thread A

Shiaber Shaam
Ranch Hand

Joined: Jun 16, 2006
Posts: 252
Hi

I have 5 instances of Thread A running.

threada1.start();
threada2.start()
threada3.start()
threada4.start()
threada5.start()

after these 5 threads get complete, i want to start an instance of thread b. may i know how to implement this.


Thanks


$Hi/\bEr
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61095
    
  66

Please be sure to take the time to compose descriptive subjects for your posts; read this for more information.

A title such as "need a soluton" is not helpful. What would happen if all posts had such a title?

Please go back and change your post to add a more meaningful subject by clicking the button on your post.

[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
Sebastian Janisch
Ranch Hand

Joined: Feb 23, 2009
Posts: 1183
You could write a multiple thread executor that fires an event once it's done.


JDBCSupport - An easy to use, light-weight JDBC framework -
Ireneusz Kordal
Ranch Hand

Joined: Jun 21, 2008
Posts: 423
You could use CountDownLatch to make one thread wait for completion of other threads:
http://java.sun.com/j2se/1.5.0/docs/api/java/util/concurrent/CountDownLatch.html
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Thread B has to start after completion of 5 instances of Thread A