Stop « Socket « Java Thread Q&A

Home
Java Thread Q&A
1.concurrency
2.Development
3.Exception
4.Notify
5.Operation
6.Socket
7.State
8.synchronize
9.Thread Safe
10.ThreadPool
Java Thread Q&A » Socket » Stop 

1. Java Socket's app randomly stopping    stackoverflow.com

Server

public void run () {

 Socket serversocket = new ServerSocket(port);
 while(true) {
   new Thread(new ServerThread(serverSocket.accept())).start();
 }
}
//serverSocket.close(); etc
ServerThread
public void run() {
 BufferedReader in = new BufferedReader(new InputStreamReader(clientSocket.getInputStream()));

 String input;

 while(true) ...

2. How do I thread with sockets so that the program doesn't stop    stackoverflow.com

It seems that when I use the accept method from the Socket class the whole program freezes up until data comes through. I've passed the socket to a thread and it ...

java2s.com  | Contact Us | Privacy Policy
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.