code: public void loop(int count) throws ExecutionException, InterruptedException {
          if (count == -1) {
              while (true) {
                  print(context.nextPacket());
              }
          } else {
              for (int i = 0; i < count; i++) {
                  print(context.nextPacket());
              }
              executorService.shutdownNow();
          }
      }
docs: Loop.
  @param count count.
  @throws ExecutionException execution exception.
  @throws InterruptedException intterrupted exception.