A Simple Wait / Notify in Java

16 2019
  • Create a object called “lock”.
private Object lock = new Object();
  • Call the wait() where you want to stop the code.
synchronized (lock)
  • Call the notify() in somewhere else in the code to proceed to the next line of wait().
synchronized (lock) {

Leave a Reply

Your email address will not be published. Required fields are marked *