public synchronized void cancelIfKilled(Future<?> f){
  cleanFuturesToKill();
  if (isKilled()) {
    f.cancel(true);
  }
  futureToCancel.add(new WeakReference<>(f));
}

public synchronized void cancelIfKilled ( Future < ? > f ) { cleanFuturesToKill ( ) ; if ( isKilled ( ) ) { f . cancel ( true ) ; } futureToCancel . add ( new WeakReference < > ( f ) ) ; }
registers a future to be cancelled when this thread is killed .
