📄 filter.java
字号:
/*
@author j.n.magee 14/08/98
*/
package concurrency.primes;
import concurrency.connector.*;
class Filter extends Thread {
private PrimesCanvas display;
private Pipe in,out;
private int index;
Filter(Pipe i, Pipe o, int id, PrimesCanvas d)
{in = i; out=o;display = d; index = id;}
public void run() {
int i,p; Integer v;
try {
v = (Integer)in.get();
p=v.intValue();
display.prime(index,p);
if (p==Primes.EOS && out!=null) {
out.put(v); return;
}
while(true) {
v = (Integer)in.get();
i=v.intValue();
display.print(index,i);
sleep(1000);
if (i==Primes.EOS) {
if (out!=null) out.put(v); break;
} else if (i%p!=0 && out!=null)
out.put(v);
}
} catch (InterruptedException e){}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -