How to pause execution of some Thread. I have Thread t and I have two buttons, PAUSE and CONTINUE. On pause I need to pause thread execution and on continue to thread start
Threading in Java is cooperative, which means you can not force the thread to stop or pause, instead you signal to the thread what you want and thread (= your logic) does it itself.
Use synchronized, wait() and notify() for that.
synchronized
block.wait()
on a common object (possibly itself). commonObject.notify()
.