public void add(final Runnable task){
synchronized (cleanup) {
    if (ran) {
      throw new IllegalStateException("Request has already been cleaned up");
    }
    cleanup.add(task);
  }
}

public void add ( final Runnable task ) { synchronized ( cleanup ) { if ( ran ) { throw new IllegalStateException ( "Request has already been cleaned up" ) ; } cleanup . add ( task ) ; } }
register a task to be completed after the request ends .
