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

📄 iothread.java

📁 source code for fishnet
💻 JAVA
字号:
import java.lang.Thread;import java.util.LinkedList;import java.io.InputStreamReader;import java.io.BufferedReader;public class IOThread extends Thread {    LinkedList inputLines;   // in 1.5, was LinkedList<String> inputLines;    BufferedReader reader;    public IOThread() {	this.inputLines = new LinkedList();	this.reader = new BufferedReader(new InputStreamReader(System.in));    }    public void run() {	while(true) {	    try {				this.addLine(this.reader.readLine());	    }catch(Exception e) {		System.err.println("Exception while waiting for user input. Exception: " + e);	    }	}    }    public synchronized boolean isEmpty() {	return this.inputLines.isEmpty();    }    public synchronized String readLine() {	if (this.inputLines.size() > 0) {	    return (String) this.inputLines.removeFirst();	} else {	    return null;	}	// in 1.5, this if/else block was return this.inputLines.poll();    }    protected synchronized void addLine(String line) {	this.inputLines.add(line);	this.notifyAll();    }}

⌨️ 快捷键说明

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