Пример #1
0
 @Override
 public void run() {
   try {
     ClientConnection cc = null;
     while (true) {
       // Accept client connections
       Socket socket = serverSocket.accept();
       // Clean up old connection
       if (oldSocket != null) {
         try {
           oldSocket.close();
         } catch (IOException e) {
           // Ignore
         }
       }
       if (cc != null) {
         // Close old worker
         cc.close();
       }
       oldSocket = socket;
       cc = new ClientConnection(handler, privateKey, socket);
       cc.start();
     }
   } catch (Exception e) {
     e.printStackTrace();
   }
   gui.exit();
 }
Пример #2
0
  @Override
  public void run() {

    while (continueWorking) {

      try {
        A a = queue.take();
        System.out.println("RECEIVED " + a.toString());
        ClientConnection cc = new ClientConnection(a);
        cc.start();
      } catch (InterruptedException ex) {

        this.dgSocket.close();
        this.continueWorking = false;
        this.child.valid = false;
        this.child.interrupt();
        this.interrupt();
      }
    }
  }