读书人

JAVA多线程设计形式六 Read-Write Pat

发布时间: 2012-09-10 22:20:12 作者: rapoo

JAVA多线程设计模式六 Read-Write Pattern

到目前为止非常有用的一个模式。

?

?

?

?

public class Main {    public static void main(String[] args) {        Data data = new Data(10);        new ReaderThread(data).start();        new ReaderThread(data).start();        new ReaderThread(data).start();        new ReaderThread(data).start();        new ReaderThread(data).start();        new ReaderThread(data).start();        new WriterThread(data, "ABCDEFGHIJKLMNOPQRSTUVWXYZ").start();        new WriterThread(data, "abcdefghijklmnopqrstuvwxyz").start();    }}

?

?

?

自己实现的逻辑锁定。

读书人网 >软件开发

热点推荐