LinuxQuestions.org
Latest LQ Deal: Latest LQ Deals
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 10-01-2004, 06:03 PM   #1
true_atlantis
Member
 
Registered: Oct 2003
Distribution: fedora cor 5 x86_64
Posts: 639

Rep: Reputation: 30
java multithreading wait for all threads to die


i have a problem, i create an aribrary number of threads in a for loop wich i want to run cuncurrently, but i need to wait for all of them to be finished executing before i can continue... anyone know if this is possible??

Code:
			Sum thesum = new Sum(N);
			for(int i=0; i<N; i++){
				childProcess thread = new childProcess(N, i, darray[i], thesum);
				thread.start();
			}
                        //WHAT CAN I PUT HERE?
			thesum.print();
 
Old 10-01-2004, 06:26 PM   #2
aaa
LQ Guru
 
Registered: Jul 2003
Location: VA
Distribution: Slack 10.1
Posts: 2,194

Rep: Reputation: 47
you could set up something with Object.wait() and Object.notify()... make a flag object, make the main thread wait on it. and have the other threads call notify when they're done.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Java threads listed using kill -3 does not contain all threads found using ps -auxww coneheed Programming 2 11-14-2005 08:57 AM
java: multithreading ashirazi Programming 5 06-23-2005 09:50 AM
java threads poeta_boy Programming 1 06-14-2005 04:34 PM
Java Threads vs Native Threads rjmendez Programming 0 08-16-2004 05:58 AM
Java: wait until first dialog is closed before displaying the other one? gundelgauk Programming 2 08-13-2004 06:57 AM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 02:00 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration