Object sychronized and thread notifyAll

来源:互联网 发布:有网络真好作文800字 编辑:程序博客网 时间:2024/06/01 19:41

find out a snip of multi-thread testing code.  when try to run it on NetBeans, encounter an error

IllegalMonitorStateException: current thread not owner

 

After investigation, find out the root cause is:

can't do a notifyAll without having a lock on the object first.

 

 

So record it as a knowledge capture.

 

 

code as following:

Main.java


Forum.java

 

Member.java