controllerThread
sets the suspendRequested
flag to true
when it wants to pause threadA
. threadA
checks this flag if it's in run()
method and, if it's set, it enters a waiting state using wait()
or Thread.sleep()
. To resume threadA
, the controlling thread sets suspendRequested
back to false
and calls notify()
to wake threadA
up.