Threads synchronizing in Java, IllegalMonitorStateException
问题 I am trying to synchronize two threads - the "Main" thread, and a runnable. I get the IllegalMonitorStateException, but I do not completelty understand what "you do not have the lock of the object" means. Here is my code: public class ThreadsTest { private static ThreadsTest instance; public volatile boolean flag = false; public void doStuff() { System.out.println("first"); this.flag = true; } public Runnable mDrawer = new Runnable() { public void run() { synchronized (ThreadsTest.getInstance