是由于在调用notify或wait方法时,没有获取到对象锁,好比这种写法java
try { "".wait(); } catch (InterruptedException e) { e.printStackTrace(); }
只要改为这样既可code
try { String str=""; synchronized (str){ "".wait(); } } catch (InterruptedException e) { e.printStackTrace(); }