operator/src/main/java/oracle/kubernetes/operator/work/Fiber.java
boolean cancelAndExitCallback(boolean mayInterrupt, ExitCallback exitCallback) {
    // Mark fiber as cancelled, if not already done
    status.compareAndSet(NOT_COMPLETE, CANCELLED);

    if (LOGGER.isFinerEnabled()) {
      LOGGER.finer("{0} cancelled", getName());
    }

    AtomicInteger count = new AtomicInteger(1); // ensure we don't hit zero before iterating
    // children
    synchronized (this) {
      if (currentThread != null) {
        if (mayInterrupt) {
          currentThread.interrupt();
        }
        count.incrementAndGet();
      }

      ExitCallback preexistingExitCallback = this.exitCallback;
      ExitCallback myCallback =
          () -> {
            if (count.decrementAndGet() == 0) {
              if (preexistingExitCallback != null) {
                preexistingExitCallback.onExit();
              }
              exitCallback.onExit();
            }
          };

      if (children != null) {
        for (Fiber child : children) {
          if (child.cancelAndExitCallback(mayInterrupt, myCallback)) {
            count.incrementAndGet();
          }
        }
      }

      boolean isWillCall = count.get() > 1; // more calls outstanding then our initial buffer count
      if (isWillCall) {
        this.exitCallback = myCallback;
        myCallback.onExit(); // remove the buffer count
      }

      return isWillCall;
    }
  }
/**
   * Cancels this fiber and accepts a callback for when the current thread, if any, exits
   * processing this fiber. Since the fiber will now be cancelled or done, no thread will re-enter
   * this fiber. If the return value is true, then there is a current thread processing in this
   * fiber and the caller can expect a callback; however, if the return value is false, then there
   * is no current thread and there will be no callback.
   *
   * @param mayInterrupt if cancel should use {@link Thread#interrupt()}
   * @param exitCallback Callback for when current thread, if any, finally exits the fiber
   * @return true, if there is a current thread executing in the fiber and that callback will
   *     eventually occur
   */
Cancels this fiber and accepts a callback for when the current thread, if any, exits
processing this fiber. Since the fiber will now be cancelled or done, no thread will re-enter
this fiber. If the return value is true, then there is a current thread processing in this
fiber and the caller can expect a callback; however, if the return value is false, then there
is no current thread and there will be no callback.

@param mayInterrupt if cancel should use  Thread#interrupt()
@param exitCallback Callback for when current thread, if any, finally exits the fiber
@return true, if there is a current thread executing in the fiber and that callback will
eventually occur
Cancels this fiber and accepts a callback for when the current thread if any exits processing this fiber . Since the fiber will now be cancelled or done no thread will re - enter this fiber . If the return value is true then there is a current thread processing in this fiber and the caller can expect a callback ; however if the return value is false then there is no current thread and there will be no callback . @param mayInterrupt if cancel should use Thread#interrupt () @param exitCallback Callback for when current thread if any finally exits the fiber @return true if there is a current thread executing in the fiber and that callback will eventually occur
boolean cancelAndExitCallback(boolean mayInterrupt, ExitCallback exitCallback) {
    status.compareAndSet(NOT_COMPLETE, CANCELLED);
    if (LOGGER.isFinerEnabled()) {
      LOGGER.finer("{0} cancelled", getName());
    }
    AtomicInteger count = new AtomicInteger(1); 
    synchronized (this) {
      if (currentThread != null) {
        if (mayInterrupt) {
          currentThread.interrupt();
        }
        count.incrementAndGet();
      }
      ExitCallback preexistingExitCallback = this.exitCallback;
      ExitCallback myCallback =
          () -> {
            if (count.decrementAndGet() == 0) {
              if (preexistingExitCallback != null) {
                preexistingExitCallback.onExit();
              }
              exitCallback.onExit();
            }
          };
      if (children != null) {
        for (Fiber child : children) {
          if (child.cancelAndExitCallback(mayInterrupt, myCallback)) {
            count.incrementAndGet();
          }
        }
      }
      boolean isWillCall = count.get() > 1; 
      if (isWillCall) {
        this.exitCallback = myCallback;
        myCallback.onExit(); 
      }
      return isWillCall;
    }
  }
boolean cancelAndExitCallback ( boolean mayInterrupt , ExitCallback exitCallback ) { status . compareAndSet ( NOT_COMPLETE , CANCELLED ) ; if ( LOGGER . isFinerEnabled ( ) ) { LOGGER . finer ( "{0} cancelled" , getName ( ) ) ; } AtomicInteger count = new AtomicInteger ( 1 ) ; synchronized ( this ) { if ( currentThread != null ) { if ( mayInterrupt ) { currentThread . interrupt ( ) ; } count . incrementAndGet ( ) ; } ExitCallback preexistingExitCallback = this . exitCallback ; ExitCallback myCallback = ( ) -> { if ( count . decrementAndGet ( ) == 0 ) { if ( preexistingExitCallback != null ) { preexistingExitCallback . onExit ( ) ; } exitCallback . onExit ( ) ; } } ; if ( children != null ) { for ( Fiber child : children ) { if ( child . cancelAndExitCallback ( mayInterrupt , myCallback ) ) { count . incrementAndGet ( ) ; } } } boolean isWillCall = count . get ( ) > 1 ; if ( isWillCall ) { this . exitCallback = myCallback ; myCallback . onExit ( ) ; } return isWillCall ; } }
Cancels this fiber and accepts a callback for when the current thread, if any, exits
 processing this fiber.
Cancels this fiber and accepts a callback for when the current thread if any exits processing this fiber .
// Mark fiber as cancelled, if not already done // ensure we don't hit zero before iterating // children // more calls outstanding then our initial buffer count // remove the buffer count