wait() and notify() method , always IllegalMonitorStateException is happen and tell me current Thread is not Owner Why?
问题 package pkg_1; public class ExpOnWaitMethod extends Thread { static Double x = new Double(20); public static void main(String[] args) { ExpOnWaitMethod T1 = new ExpOnWaitMethod(); ExpOnWaitMethod T2 = new ExpOnWaitMethod(); T1.start(); T2.start(); } public void run() { Mag mag = new Mag(); synchronized (x) { try { for (int i = 1; i < 10; i++) { mag.nop(Thread.currentThread()); x = i * 2.0; } } catch (InterruptedException e) { e.printStackTrace(); } } } } class Mag { char ccc = 'A'; public