code: @Override
      public synchronized boolean cancel(boolean mayInterruptIfRunning) {
  
          final boolean isTraceOn = TraceComponent.isAnyTracingEnabled();
  
          if (isTraceOn && tc.isEntryEnabled())
              Tr.entry(tc, "cancel - Future object: " + this, mayInterruptIfRunning);
  
          boolean cancelled = false;
  
          // F743-11774 - If we have not already canceled the work, then attempt
          // to remove it from the queue.  Note that if the work is removed from
          // the queue prior to executing, then there will be no opportunity for
          // wasCancelCalled to be called, so it is unnecessary to set
          // ivWasCancelCalled.
          if (!ivCancelled) {
              if (isTraceOn && tc.isDebugEnabled())
                  Tr.debug(tc, "attempting to remove from work queue");
  
              cancelled = doCancel();
              if (cancelled) {
                  ivCancelled = true;
                  done();
                  // F743-22763
                  if (ivPmiBean != null) {
                      ivPmiBean.asyncMethodCallCanceled();
                      ivPmiBean.asyncQueSizeDecrement();
                  }
              } else {
                  ivWasCancelCalled = mayInterruptIfRunning;
              }
          }
  
          if (isTraceOn && tc.isEntryEnabled())
              Tr.exit(tc, "cancel", cancelled);
  
          return (cancelled);
      }
docs: Cancel the async method if possible. If the method is still waiting on a
  work manager queue and has not been dispatched, we can cancel it.
  Otherwise, it is not likely that the method will be able to stop
  execution.<p>
  
  This method is releases the gate when cancel is successful
  just in case there is another client thread waiting in a "get"
  method below (this is not really expected to happen).
  
  @param mayInterruptIfRunning
  
  @return - true if the method was successfully canceled. Otherwise, false.