Indeed, pausing or stopping threads at random points is an unsafe idea, so these methods are deprecated.
The best thing you can do, in my opinion, is to have fixed pause points in your threading run
method and stop there using wait
:
class ThreadTask implements Runnable { private volatile boolean paused; private final Object signal = new Object(); public void run() {
Tudor source share