大家帮我看看这个程序有会么问题。
package ConsoleApplication1;import *;
import java.util.*;
class Sender extends Thread{
private PipedOutputStream out = new PipedOutputStream();
public PipedOutputStream getPipedOutputStream() {
return out;
}
public void run(){
try{
for(int i=-127;i<=128;i++){
out.write(i);
yield();
}
out.close();
}catch(Exception e){
throw new RuntimeException(e);
}
}
}
public class Receiver extends Thread {
private PipedInputStream in;
public Receiver(Sender sender) throws IOException{
in = new PipedInputStream(sender.getPipedOutputStream());
}
public void run() {
try{
int date;
while((date=in.read())!=-1)
System.out.println(date);
in.close();
}catch(Exception e){
throw new RuntimeException(e);
}
}
public static void main(String args[])throws Exception {
Sender sender = new Sender();
Receiver reveiver = new Receiver(sender);
sender.start();
reveiver.start();
}
}