code: public synchronized ScheduledFuture scheduleTimeout(final int sequenceNumber, long time, TimeUnit unit)
      {
          if (!files.containsKey(sequenceNumber))
              return null;
  
          ScheduledFuture future = timeoutExecutor.schedule(new Runnable()
          {
              public void run()
              {
                  synchronized (StreamTransferTask.this)
                  {
                      // remove so we don't cancel ourselves
                      timeoutTasks.remove(sequenceNumber);
                      StreamTransferTask.this.complete(sequenceNumber);
                  }
              }
          }, time, unit);
  
          ScheduledFuture prev = timeoutTasks.put(sequenceNumber, future);
          assert prev == null;
          return future;
      }
docs: Schedule timeout task to release reference for file sent.
  When not receiving ACK after sending to receiver in given time,
  the task will release reference.
  
  @param sequenceNumber sequence number of file sent.
  @param time time to timeout
  @param unit unit of given time
  @return scheduled future for timeout task