protected static Object lock;
public void awake(){
synchronized (lock){
if(Thread.currentThread().isAlive()){
Thread.currentThread().notify();
}
}
}
I am using this code in a synchronized block so that my main method has a monitor of the thread and doesn't receive a IllegalMonitorStateException.
I don't understand why this is giving me a nullpointer exception. The thread has to be alive to execute the thread.notify command, and the lock is a static object. Nothing can be null. Any ideas?