代碼不是太長,就是下面這段代碼,首先看一下,憑感覺回答有沒有問題,然後運行一下。
public class Test {
public synchronized void t(){
new Thread(new Fuzhu()).start();
}
public static void main(String[] args) {
new Test().t();
}
}
class Fuzhu implements Runnable{
public void run() {
try {
this.wait(1000);
} catch (Exception e) {
e.printStackTrace();
}
}
}
運行之後,有誰能回答一下,為什麼回報 java.lang.IllegalMonitorStateException: current thread not owner 這個異常.
作者“wpskl”