Ejemplo n.º 1
0
    public void run() {

      for (int i = 1; i <= number_of_msgs; i++) {
        try {
          Message msg = new Message(null, buf);
          if (oob) msg.setFlag(Message.Flag.OOB);
          if (dont_bundle) msg.setFlag(Message.Flag.DONT_BUNDLE);
          if (i > 0 && do_print > 0 && i % do_print == 0) System.out.println("-- sent " + i);

          Buffer buffer = writeMessage(msg);

          output_lock.lock(); // need to sync if we have more than 1 sender
          try {
            // msg.writeTo(output);
            output.writeInt(buffer.getLength());
            output.write(buffer.getBuf(), buffer.getOffset(), buffer.getLength());
            // output.flush();
          } finally {
            output_lock.unlock();
          }
        } catch (Exception e) {
          e.printStackTrace();
        }
      }
    }