wood burning stoves 2.0*
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

Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "Threads and join" Watch "Threads and join" New topic

Threads and join

Roel De Nijs

Joined: Jul 19, 2004
Posts: 5126

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
Paul Clapham

Joined: Oct 14, 2005
Posts: 18541

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

Joined: Jul 19, 2004
Posts: 5126

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 ?
wood burning stoves
subject: Threads and join
Similar Threads
thread join problem statement
How to wait until all threads finishes task?
sequential execution of threads
Multithreading doubt
Thread dependency