Guest User

Untitled

a guest
Jul 23rd, 2018
72
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.82 KB | None | 0 0
  1. public void run(){
  2. synchronized(this){
  3. this.runningThread = Thread.currentThread();
  4. }
  5. openServerSocket();
  6. while(! isStopped()){
  7. Socket clientSocket = null;
  8. try {
  9. clientSocket = this.serverSocket.accept();
  10. } catch (IOException e) {
  11. if(isStopped()) {
  12. System.out.println("Server Stopped.") ;
  13. return;
  14. }
  15. throw new RuntimeException(
  16. "Error accepting client connection", e);
  17. }
  18. this.threadPool.execute(
  19. new WorkerRunnable(clientSocket,
  20. "Thread Pooled Server"));
  21. }
  22. this.threadPool.shutdown();
  23. System.out.println("Server Stopped.") ;
  24. }
Add Comment
Please, Sign In to add comment