Following code produces number sequentially. There will be only one such producer, However there can be many threads to pause/resume the list of sequential numbers.package pauseresume;public class Sequential implements Runnable {  volatile boolean pause;  @Override  public void run() {    long i = 0;    while (true) {      while (pause) {        synchronized (this) {          try {            wait();          } catch (InterruptedException e) {          }        }      }      System.out.println(i);      try {        Thread.sleep(10);      } catch (InterruptedException e) {      }      i++;    }  }  public synchronized void pause() {    pause = true;  }  public synchronized void resume() {    pause = false;    notifyAll();  }}Does the code seems thread-safe?
Pause & Resume producer
java;concurrency