• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

wait 2 thread is finish before to continue the program

 
mark smith
Ranch Hand
Posts: 251
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi

when i click on a button, i would like to start action. When theses both actions would be finish, i want to start another action, this one need the result of both actions previous terminated.

any idea?

thanks
 
Mohana Rao Sv
Ranch Hand
Posts: 485
Eclipse IDE Firefox Browser Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
what you have been tried?
 
Steve Luke
Bartender
Posts: 4181
21
IntelliJ IDE Java Python
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
In addition to showing what you have tried and where you have problems, consider this:

You have two actions that need to run sequentially, and whose results need to be shared. Threads are about running code concurrently, which you don't need. Sharing results between threads requires synchronization, which can be complicated. So why are you considering using Threads for this application when you don't need them for what they do and only complicate matters? Why not just run task 1 to completion, then run task 2 to completiion in the same code stream?
 
mark smith
Ranch Hand
Posts: 251
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
why to use thread to do 2 actions in same time? hum performance?

i think a solution would be to start 2 thread and use join on them to start another operation
 
Paul Clapham
Sheriff
Posts: 20989
31
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
mark smith wrote:i think a solution would be to start 2 thread and use join on them to start another operation


Well, that's what I was going to suggest: to wait for a Thread to finish, you call its join() method. But it looks like you have figured that out for yourself. So can we flag this thread as resolved?
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic