我正在做一个项目,在这个项目中,我需要循环队列和线程来模拟火车上下客。我使用Object.notify和Object.wait来控制线程。at java.lang.Object.notify(Native Method) at java.lang.Thread.run(); // notify the train to let the
我正在读“multi threading in Java”一书中的“”。我发现下面是Pg代码。252,第7版。这解释了wait()和notify()在现代Java中对suspend和resume线程的使用。(this) { //First doubt here wait()我尝试以不同的方式同时在每个地方删除sy
import java.util.*;import java.util.regex.*;
Exception in thread "main" java.lang.IllegalMonitorStateException
at java.lang.Object.notify在上面的示例中,会在"sa“对象上调用wait
should return the first future") { p completeWith Future.any(List(Future{wait(2000); 1}, Future{wait(1); 2})) assert(true) }[info] The future returned an exception of
"Thread-0" java.lang.IllegalMonitorStateException atjava.lang.Object.wait(Object.java:485)
at concurrency.LeftLegThread.makeStep(LeftRightWaitNotifyExample.java-1" ja