Posted By:
Glenn_Wiebe
Posted On:
Wednesday, August 29, 2001 11:25 AM
I have a main thread that creates an object with a Runnable interface, creates a thread out of it and then starts it. The main thread then waits for 180 seconds on the object. If after the timeout period, the object has not done its work, I want to stop the old object, create a new one and try again. Unfortunately the wait(180000) never times out!!! Thanks for any help. Glenn Consumer: RptGetter rmGet = new RptGetter(mSid, mRptMgr, mRptId, mKv, kTagList, mDebugLevel); Thread rgt = new Thread(rmGet); rgt.start(); synchronized(rmGet) { rmGet.wait(180000); if (!rmGet.done) { // NOT DONE - stop the thread rg
More>>
I have a main thread that creates an object with a Runnable interface, creates a thread out of it and then starts it. The main thread then waits for 180 seconds on the object. If after the timeout period, the object has not done its work, I want to stop the old object, create a new one and try again.
Unfortunately the wait(180000) never times out!!!
Thanks for any help.
Glenn
Consumer:
RptGetter rmGet = new RptGetter(mSid, mRptMgr, mRptId, mKv, kTagList, mDebugLevel);
Thread rgt = new Thread(rmGet);
rgt.start();
synchronized(rmGet) {
rmGet.wait(180000);
if (!rmGet.done) {
// NOT DONE - stop the thread
rgt.stop();
} else {
// DONE - get report and continue
mTds = rmGet.getTDS();
gotRpt = true;
} // end else if done
Producer:
class RptGetter implements Runnable {
public void run() {
synchronized (this) {
tds = rptMgr.getReport
done = true;
this.notifyAll();
} // end synchronized code
} // end run method
<<Less