This week's book giveaway is in the Mac OS forum.
We're giving away four copies of a choice of "Take Control of Upgrading to Yosemite" or "Take Control of Automating Your Mac" and have Joe Kissell on-line!
See this thread for details.
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes Threads and join Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "Threads and join" Watch "Threads and join" New topic
Author

Threads and join

Roel De Nijs
Bartender

Joined: Jul 19, 2004
Posts: 5299
    
  13

I have a question about joining of threads: i have 3 threads (t1, t2 and t3). t1 can't start unless t3 has finished his job. and t2 can't start unless t1 has ended.

how do you do this in code? where do you place the instance.join() methods?


SCJA, SCJP (1.4 | 5.0 | 6.0), SCJD
http://www.javaroe.be/
Paul Clapham
Bartender

Joined: Oct 14, 2005
Posts: 18570
    
    8

You put that code in some class that controls the action of those three threads. Like this:I suppose this must be a simplified example of your real problem, though, because it doesn't need threads at all. Just call the three bits of code designated as "..." one after the other.
[ October 23, 2005: Message edited by: Paul Clapham ]
Roel De Nijs
Bartender

Joined: Jul 19, 2004
Posts: 5299
    
  13

no it's not a simplified version of a real world problem. i do know what the purpose of the join method is, but i don't know what it means if you call t1.join()

if you call t1.join() from the run-method of t2 will then t2 wait until t1 has finished ?
 
GeeCON Prague 2014
 
subject: Threads and join