public class WorkerThread implements Runnable {
  private volatile boolean _shutdownRequested = false;

  public void shutdownRequest() {
    _shutdownRequested = true;
    Thread.currentThread().interrupt();
  }

  public void run() {
    try {
      while (!_shutdownRequested) {
      System.out.println("現在動いています");
      Thread.sleep(3000);
    }
    } catch (InterruptedException e) {
    } finally {
      doShutdown();
    }
  }

  private void doShutdown() {
    System.out.println("このメソッドを実行してから、終了します");
  }
}