blackberry - how to end a thread when it is in sleep? -
I am creating a project in which I decrease the schedule after some time, I calculate the time that the method of sleep In time if I change time again, then I want to end the last thread and start a new thread. That is why I want to know how it is in the method of sleep, to finish it without executing the method of running it.
When I'm programming for Blackberry, do I believe in Java?
If yes, then do not wait for thread.leep ()
, but do not use wait ()
on a monitor, which you Then can notify all ()
, ie
private object waitObject = new object (); Public Zero doWait () {synch (waitObject) {waitObject.wait (10 * 1000); // Wait for 10 seconds}} Public Zero Outgoing Up () {Synchronize (Waiting Object) {waitObject.notifyAll (); }}
Synchronized
blocks are important, because you need to be the owner of that monitor that you want to wait or inform on Are there.
Comments
Post a Comment