Hi, I have some code running which consists of a GUI. At one point, a long
running task must be executed. So the code looks like:
// some code
// progress monitor code
longTask.go()
// do something with the results of long task
The problem is, that the code that calls longTask.go() must wait for
longTask to finish. I created long task based on the examples for the
ProgressMonitor class on the Java website. However the difference is that
I must wait till the thread that longTask is in finishes.
So I modified it to:
// some code
// progress monitor code
longTask.go()
try {
this.wait()
} catch(..) {}
// do stuff with the results of long task
However, what I don't understand is how I can get the current thread (ie
the one that is waiting) to start running again once longTask has
completed.
I hope I've been able to describe the problem as I'm a newbie to threads.
Any pointers would be appreciated
Thanks,
Rajarshi
Paul Hamaker - 30 Apr 2006 23:16 GMT
Use notify() from a thread to alert another waiting thread that it is
getting a chance to continue.
http://javalessons.com/cgi-bin/fun/java-tutorials-main.cgi?ses=ao789&code=th2&sub=adv
is about threads that operate in turn, one waiting for the other.
--------------------
Paul Hamaker, SEMM, teaching ICT since 1987
http://javalessons.com