readfrompipe.java
来自「Practical Java也是一本和J2ME手机游戏开发相关的书」· Java 代码 · 共 24 行
JAVA
24 行
class ReadFromPipe extends Thread
{
private Pipe pipe;
//...
public void run()
{
int data;
while(true)
{
while((data = pipe.getData()) == 0)
{
//No data, so sleep for a while and try again.
try {
sleep(200);
}
catch(InterruptedException e){} //Exception is ignored
} //purposefully.
synchronized(pipe) {
//Process data
}
}
}
}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?