public class Blocked extends Thread {
public Blocked() {
start();
}
public void run() {
try {
wait();
} catch (InterruptedException e) {
...
}
}
public static void main(String[] args) {
new Blocked();
}
}
跑起来坏掉了
Exception in thread "Thread-0" java.lang.IllegalMonitorStateException: current thread not owner
at java.lang.Object.wait(Native Method)
at java.lang.Object.wait(Object.java:474)
at Blocked.run(Blocked.java:8)