有什么问题
private final Object lock;
public synchronized void run() {
while (numItersCompleted < maxNumIters) {
while (guiState == GuiState.PAUSED) {
try {
lock.wait(); // problematic line
抛出:
java.lang.IllegalMonitorStateException
at java.lang.Object.wait(Native Method)
at java.lang.Object.wait(Object.java:502)
答案 0 :(得分:0)
锁定时没有synchronized
。
public void run() {
while (numItersCompleted < maxNumIters) {
while (guiState == GuiState.PAUSED) {
try {
synchronized (lock) {
lock.wait(); // problematic line
}
我打算添加一个链接,但加里打赌我这个