是由於在調用notify或wait方法時,沒有獲取到對象鎖,好比這種寫法java
try { "".wait(); } catch (InterruptedException e) { e.printStackTrace(); }
只要改爲這樣既可code
try { String str=""; synchronized (str){ "".wait(); } } catch (InterruptedException e) { e.printStackTrace(); }