hi all
i doing a stop watch. for pause i use Thread.suspend() and resume i use Thread.resume(). but the resume is not resume the work.
code:
pause(){
shouldRun = false;
currentThread.suspend();
}
resume(){
shouldRun = true;
currentThread.resume();
}
while(shouldRun){
…….
}
There’s a reason why
Thread.suspend()andThread.resume()are deprecated – they’re not a good idea for various reasons. Most importantly, the thread itself is in the best position to know how to pause safely (e.g. while not holding a lock).I urge you to reconsider your design to avoid using suspend/resume. If you tell us more about what you’re trying to achieve, we may be able to help you more.