在后面加上一句看看这个线程终止了没有?
/觉得很怪,你是怎么在writeThread中得到 Socket client的?
public static void processSend(byte[] sourceStr) {
try{
writeData= new DataOutputStream(client.getOutputStream());
}catch(IOException e){}
writeThread write=new writeThread(sourceStr);
write.start();
try{
write.join();
}catch(InterruptedException e){
}
System.out.printlne("send finish!");
}
/觉得很怪,你是怎么在writeThread中得到 Socket client的?
public static void processSend(byte[] sourceStr) {
try{
writeData= new DataOutputStream(client.getOutputStream());
}catch(IOException e){}
writeThread write=new writeThread(sourceStr);
write.start();
try{
write.join();
}catch(InterruptedException e){
}
System.out.printlne("send finish!");
}
解决方案 »
- JDK代理的原理是怎样的,代码如何实现?
- 怎么实现没有触发任何事件而窗口自己重绘?
- 线程参数传递不正确
- 人民币数字转化为文字,如1235怎么输出一千二百三十五元?
- 帮忙看看这题
- 初学者求学习好书,100分送上
- 为什么我在import javax.servlet.*;的时候会出现错误
- 请教各位大神一个关于java swing的问题
- tomcat4.1的连接池如何配置?
- 我想了解一下Java的消息映射机制,有谁知道吗??
- JAVA中如何调用WINDOWS系统的API 感激!!!!!!!!!!!!!!
- 急问:如何将java.util.Date转换成java.sql.Date,来算出两个日期相差天数?
static final class readThread extends Thread{
ByteArrayOutputStream aos; public void run(){ BufferedInputStream bis=new BufferedInputStream(readData);
aos=new ByteArrayOutputStream();
try {
byte[] buf=new byte[1024];
while(true){
int count=bis.read(buf,0,1024);
if(count==-1)break;
aos.write(buf,0,count);
}
} catch (Exception e) {
System.out.println("Error read data ");
}
}
}
static final class writeThread extends Thread{
private byte[] source;
public writeThread(byte[] source){
this.source=source;
}
public void run(){
try {
writeData.write(source);
writeData.flush();
} catch (IOException e) {
System.out.println("Error reading from file: " +new String(source));
}
}
}
我需要的是client端进程