This week's book giveaway is in the JavaScript forum.
We're giving away four copies of Cross-Platform Desktop Applications: Using Node, Electron, and NW.js and have Paul Jensen on-line!
See this thread for details.
Win a copy of Cross-Platform Desktop Applications: Using Node, Electron, and NW.js this week in the JavaScript forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Threads and join  RSS feed

 
Roel De Nijs
Sheriff
Posts: 11333
177
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: 22374
42
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: 11333
177
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 ?
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!