Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / GUI / April 2006

Tip: Looking for answers? Try searching our database.

gettting a wait()'ing thread to run again

Thread view: 
Rajarshi Guha - 29 Apr 2006 23:39 GMT
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


Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.