Esempio n. 1
0
    public ConnectionContext(String log_dir, Socket local, Socket remote) throws Exception {
      this.local_sock = local;
      this.remote_sock = remote;

      String log_file = log_dir + "/" + UUID.randomUUID().toString() + ".txt";
      System.out.println("Starting connection: " + log_file);

      log_out = new PrintStream(new FileOutputStream(log_file));

      open = true;

      local_reader = new ReaderThread(this, local_sock, remote_sock, "local");
      local_reader.start();
      remote_reader = new ReaderThread(this, remote_sock, local_sock, "remote");
      remote_reader.start();
    }
Esempio n. 2
0
  public static void main(String[] args) throws IOException {
    // read count of strings
    int count = Integer.parseInt(reader.readLine());

    // init threads
    ReaderThread consolReader1 = new ReaderThread();
    ReaderThread consolReader2 = new ReaderThread();
    ReaderThread consolReader3 = new ReaderThread();

    while (count > countReadStrings) {}

    consolReader1.interrupt();
    consolReader2.interrupt();
    consolReader3.interrupt();
    System.out.println("#1:" + consolReader1);
    System.out.println("#2:" + consolReader2);
    System.out.println("#3:" + consolReader3);

    reader.close();
  }