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

📄 multiplexio.java

📁 source code for fishnet
💻 JAVA
字号:
import java.lang.Thread;import java.io.IOException;import java.io.PipedInputStream;import java.io.PipedOutputStream;import java.util.LinkedList;public class MultiplexIO extends Thread {        private PipedInputStream input;    private PipedOutputStream output;    private LinkedList data;  // in 1.5, was private LinkedList<Integer> data;    public MultiplexIO() throws IOException {	this.input = new PipedInputStream();	this.output = new PipedOutputStream(this.input);	this.data = new LinkedList();    }    public void run() {	while(true) {	    try {		this.store(this.input.read());	    }catch(Exception e) {		System.err.println("Exception occured while waiting for IO channels. Exception: " + e);	    }	}    }    public synchronized void write(int b) throws IOException {	this.output.write(b);    }    public synchronized int read() {	if(!this.isEmpty()) {	    return ((Integer) this.data.removeFirst()).intValue();	    // in 1.5 was return this.data.poll().intValue();	}	return -1;    }    public synchronized boolean isEmpty() {	return this.data.isEmpty();    }    private synchronized void store(int b) {	this.data.add(new Integer(b));	this.notifyAll();    }}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -