📄 fibonacciproducer.java
字号:
package javathreads.examples.ch08.example6;
import java.util.*;
import java.util.concurrent.*;
public class FibonacciProducer implements Runnable {
private Thread thr;
private BlockingQueue<Integer> queue;
public FibonacciProducer(BlockingQueue<Integer> q) {
queue = q;
thr = new Thread(this);
thr.start();
}
public void run() {
try {
for(int x=0;;x++) {
Thread.sleep(1000);
queue.put(new Integer(x));
System.out.println("Produced request " + x);
}
} catch (InterruptedException ex) {
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -