I'm new to using threads I get an IllegalMonitorStateException as soon as the wait method is called can someone help me out
public class SomeClass{
private final Thread thread = new Thread(this::someMethod);
public synchronized void someMethod(){
try {
doSomething();
TimeUnit.SECONDS.sleep(2);
doSomething();
thread.wait();
} catch (InterruptedException e) {
e.printStackTrace();
}
someMethod();
}
public synchronized void restartThread() {
thread.notify();
}
SomeClass test = new SomeClass();
test.start();