andreluizreis
6/20/2017 - 8:14 PM

Thread - Wait callback

Thread - Wait callback

// The object that will wait the other thread to unlock
final Object syncObject = new Object();

// Stop and Wait
synchronized (syncObject){
    try {
        syncObject.wait();
    } catch (InterruptedException e) {
        e.printStackTrace();
    }
}

// Release the lock and continue
synchronized (syncObject){
    syncObject.notify();
}