<T>Task<T> enqueue(Continuation<Void,Task<T>> taskStart){
  lock.lock();
  try {
    Task<T> task;
    Task<Void> oldTail=tail != null ? tail : Task.<Void>forResult(null);
    try {
      Task<Void> toAwait=getTaskToAwait();
      task=taskStart.then(toAwait);
    }
 catch (    RuntimeException e) {
      throw e;
    }
catch (    Exception e) {
      throw new RuntimeException(e);
    }
    tail=Task.whenAll(Arrays.asList(oldTail,task));
    return task;
  }
  finally {
    lock.unlock();
  }
}

< T > Task < T > enqueue ( Continuation < Void , Task < T > > taskStart ) { lock . lock ( ) ; try { Task < T > task ; Task < Void > oldTail = tail != null ? tail : Task . < Void > forResult ( null ) ; try { Task < Void > toAwait = getTaskToAwait ( ) ; task = taskStart . then ( toAwait ) ; } catch ( RuntimeException e ) { throw e ; } catch ( Exception e ) { throw new RuntimeException ( e ) ; } tail = Task . whenAll ( Arrays . asList ( oldTail , task ) ) ; return task ; } finally { lock . unlock ( ) ; } }
enqueues a task created by taskstart .
