This week's book giveaway is in the OCAJP forum.
We're giving away four copies of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) and have Khalid A Mughal & Rolf W Rasmussen on-line!
See this thread for details.
Win a copy of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) this week in the OCAJP forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Threads and join

 
Roel De Nijs
Sheriff
Posts: 10386
132
AngularJS Chrome Eclipse IDE Hibernate Java jQuery MySQL Database Spring Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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?
 
Paul Clapham
Sheriff
Posts: 21316
32
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Sheriff
Posts: 10386
132
AngularJS Chrome Eclipse IDE Hibernate Java jQuery MySQL Database Spring Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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 ?
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic