⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 filter.java

📁 演示win32的socket 通讯 八皇后的改进算法 并发Concurrency的JAVA实现 applet演示鼠标的点击时间和显示图象 手机J2ME的多线程演示
💻 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 + -