• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Unexpected SocketTimeoutException

 
Sun LiWei
Ranch Hand
Posts: 49
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have a thread which using DatagramSocket in the run() method:
MyThread extends Thread{
public void run(){
try{
DatagramSocket socket=new DatagramSocket();
socket.send(...);
socket.recieve(...);
socket.close();
}catch(Exception e){
e.printStackTrace();
}
}
}
When I generate tens of threads with MyThread, most of the threads run without exception,but there're always some threads throw a SocketTimeoutException,the network is ok though,when i run one thread a time,no exception! I can't figure it out.Help me.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic