@Override
  public synchronized Task<T> remove() {
    assertNotClosed();
    if (cache.size() == 0) {
      return wrappedCollection.remove();
    }

    final Task<T> pendingTask = cache.remove();
    outstandingTasks.add(pendingTask);
    return pendingTask;
  }
Instantiates a new Caching task collection.

@param collection the collection
services/tasks/src/main/java/org/hyperledger/besu/services/tasks/CachingTaskCollection.java