多线程报如下异常:
Exception in thread “打印机1” Exception in thread “打印机2” java.lang.IllegalMonitorStateException
at java.lang.Object.notify(Native Method)
at com.java.Number.run(PrintNumber.java:31)
at java.lang.Thread.run(Thread.java:748)
java.lang.IllegalMonitorStateException
at java.lang.Object.notify(Native Method)
at com.java.Number.run(PrintNumber.java:31)
at java.lang.Thread.run(Thread.java:748)
原因:
同步监视器(锁)和wai(),notify(),notifyAll()方法的调用对象不同导致
Exception in thread "打印机1" Exception in thread "打印机2" java.lang.IllegalMonitorStateException
最新推荐文章于 2024-05-09 01:00:00 发布