📄 writer.java
字号:
//Writer.javapackage com.wrox.syncserver;import java.util.Vector;public class Writer { /** * Put some Integers on the queue so the * readers have something to read. */ public void fill(Vector queue) { for (int i = 0; i < 20; i++) { queue.add(new Integer(i)); synchronized (queue) { queue.notifyAll(); } } } public static void main(String[] args) { // This vector will be the communication channel // between the writer and the readers. Vector queue = new Vector(); Writer writer1 = new Writer(); // Start two readers. Reader reader1 = new Reader(queue, "Reader1"); reader1.start(); Reader reader2 = new Reader(queue, "Reader2"); reader2.start(); // Fill up the queue. The waiting readers will wake up // and start emptying the queue. writer1.fill(queue); } }
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -