public void run() {
   try {
     while (true) {
       writer.println(queue.take());
     }
   } catch (InterruptedException ignored) {
   } finally {
     writer.close();
   }
 }
    public void run() {
      try {
        BufferedReader in =
            new BufferedReader(new InputStreamReader(clientConnection.getInputStream()));
        PrintWriter out = new PrintWriter(clientConnection.getOutputStream(), true);

        String lineIn = null;
        while ((lineIn = in.readLine()) != null) {
          logger.info("***** in: [{}]", lineIn);
          out.println(lineIn.toUpperCase());
        }

        logger.info("***** closing connection");
        clientConnection.close();
      } catch (IOException e) {
        e.printStackTrace();
      }
    }
  private static void saveProcessID(String svrName, String runDir) {
    Log.info("Server Name is " + svrName + " Run Dir is " + runDir);
    RuntimeMXBean rt = ManagementFactory.getRuntimeMXBean();
    String pid = rt.getName();
    if (Log.loggingDebug) {
      Log.info("PROCESS ID IS " + pid);
      Log.info("server name is " + svrName);
    }

    try {
      if (runDir != null) {
        File outFile = new File(runDir + "\\" + svrName + ".bat");
        PrintWriter out = new PrintWriter(new FileWriter(outFile));
        out.println("set pid=" + pid.substring(0, pid.indexOf("@")));
        out.close();
      }
    } catch (IOException e) {
      Log.exception("saveProcessID caught exception", e);
    }
  }
Beispiel #4
0
    public void run() {
      try {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        PrintWriter pw = new PrintWriter(socket.getOutputStream(), true);
        String msg;

        while (true) {
          msg = br.readLine();
          pw.println(msg);

          if (msg.trim().equals("-quit")) {
            pw.close();
            br.close();
            exec.shutdownNow();
            break;
          }
        }
      } catch (Exception e) {
        e.printStackTrace();
      }
    }
 public void run() {
   System.out.println("starting " + threadname + " run method on port " + SudokuServer.PORT);
   System.out.flush();
   try {
     Socket sock = new Socket(hostname, SudokuServer.PORT);
     PrintWriter dos = new PrintWriter(sock.getOutputStream());
     BufferedReader dis = new BufferedReader(new InputStreamReader(sock.getInputStream()));
     dos.println(testcase);
     dos.flush();
     String response = dis.readLine();
     System.out.println(
         "Client " + threadname + " sent: " + testcase + " received response:" + response);
     dos.close();
     dis.close();
     synchronized (sc) {
       sc.result = response;
     }
   } catch (Exception e) {
     e.printStackTrace();
   }
   System.out.println("finishing " + threadname + " run method");
 }