[2334] in java-interest
wait & notify
daemon@ATHENA.MIT.EDU (Anselm.BairdSmith)
Fri Sep 29 10:23:32 1995
Date: Fri, 29 Sep 1995 12:59:05 +0100
From: "Anselm.BairdSmith" <Anselm.Baird_Smith@inria.fr>
To: java-interest@java.sun.com
In trying to use the wait & notify Object methods, I hit a funny
problem. If I use the following class:
class WaitCondition {
synchronized void doWait (int time) {
wait (time) ;
}
synchronized void doNotify (int date) {
notifyAll () ;
}
}
The rest of the program doesn't work (ie: notifyAll doesn't wake up
the waiters). Yet, if I use this version of the class:
class WaitCondition {
int date ;
synchronized void doWait (int time) {
date = time ;
wait (time) ;
}
synchronized void doNotify (int date) {
this.date = date ;
notifyAll () ;
}
}
all runs fine ! If I don't affect the 'date' field either in doWait()
or in doNotify(), the program doesn't work. Is this some runtime bug,
or did I miss something abouth how wait & notify should work ?
Anselm.
BTW: I am implementing a Timer thread, which sends - through 1a3
Thread.postObject() - an Object after a given duration has
expired. Has anyone already done it ?
Anselm.BairdSmith@inria.fr - http://www.inria.fr/koala/abaird.html
-
Note to Sun employees: this is an EXTERNAL mailing list!
Info: send 'help' to java-interest-request@java.sun.com