File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Threads and Synchronization and the fly likes wait 2 thread is finish before to continue the program Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Threads and Synchronization
Bookmark "wait 2 thread is finish before to continue the program" Watch "wait 2 thread is finish before to continue the program" New topic
Author

wait 2 thread is finish before to continue the program

mark smith
Ranch Hand

Joined: Apr 05, 2005
Posts: 250
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

Joined: Aug 01, 2007
Posts: 485

what you have been tried?


ocjp 6 — Feeding a person with food is a great thing in this world. Feeding the same person by transferring the knowledge is far more better thing. The reason is the amount of satisfaction which we get through food is of only one minute or two. But the satisfaction which we can get through the knowledge is of life long.
Steve Luke
Bartender

Joined: Jan 28, 2003
Posts: 4181
    
  21

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?


Steve
mark smith
Ranch Hand

Joined: Apr 05, 2005
Posts: 250
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
Bartender

Joined: Oct 14, 2005
Posts: 18570
    
    8

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?
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: wait 2 thread is finish before to continue the program