// variables/fields visible to main thread and server thread:volatile boolean shouldContinue;Object sharedObject = new Object();...// In main thread (waiting):synchronized (sharedObject) { while (!shouldContinue) sharedObject.wait();}...// In server thread (notifying):synchronized (sharedObject) { shouldContinue = true; sharedObject.notifyAll();}