Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public void run(){
- synchronized(this){
- this.runningThread = Thread.currentThread();
- }
- openServerSocket();
- while(! isStopped()){
- Socket clientSocket = null;
- try {
- clientSocket = this.serverSocket.accept();
- } catch (IOException e) {
- if(isStopped()) {
- System.out.println("Server Stopped.") ;
- return;
- }
- throw new RuntimeException(
- "Error accepting client connection", e);
- }
- this.threadPool.execute(
- new WorkerRunnable(clientSocket,
- "Thread Pooled Server"));
- }
- this.threadPool.shutdown();
- System.out.println("Server Stopped.") ;
- }
Add Comment
Please, Sign In to add comment