title: Suspending a non-looping thread
body: <p>I have a thread A acting as a GUI or CLI that spawns another thread B. Thread B has its run method like below</p>
  
  <pre><code>public void run() {
      doSomething(); //Might take 30 seconds
      crazyCalculation(); //Might take 30-60 minutes
      doTheLastThingBeforeExit(); //Might take another 30 seconds
  }
  </code></pre>
  
  <p>My question is: Is it possible to pause the execution of thread B from thread A (to externally (having user looking at the log) analyze the current result) then resume thread B whenever user finishes his analysis? Is this achievable without modifying thread B's contents? (Some other way to achieve what the deprecated Thread.suspend() method does)</p>
  
  <p>If thread B's content has to be modified (I suppose with wait() and notify()), where should they be in thread B? Should I modify crazyCalculation() to have multiple stage and have my run method be</p>
  
  <pre><code>public void run() {
      doSomething();
      for (int i = 0; i &lt; numberOfStage; i++) {
          crazyCalculationAtStage(i); //Broken down to smaller chunk 1 minute each stage
          synchronized (this) {
              if (isLocked()) {
                   myLock.wait();
              }
          }
      }
      doTheLastThingBeforeExit();
  }
  </code></pre>