Description: First, perform a read operation, if they are not writers, readers who write critical region will enter writerCritical.enterCriticalSection (), until the last readership is equal to zero, leaving writers critical region, therefore, writing to execute a write operation, enter the write those critical areas, the need to wait until there are no readers so far Second, each writer to write, you must first enter the critical section writer, and synchronized keyword defined methods, making at the same time synchronization method allowed to be repeated call, which guarantees not have two write work simultaneously. Therefore, only one written on the file for write access.
To Search:
File list (Check if you may need any files):
代码和文档\java编写的信号量解决读者和写者的问题.doc
..........\readerandwriter\MainEnter.java
..........\...............\MainFrame.java
..........\...............\ReaderCritical.java
..........\...............\ReadWriteThread.java
..........\...............\WriterCritical.java
..........\readerandwriter
代码和文档