final boolean abort ( boolean removeFromQueue , Throwable cause ) { if ( removeFromQueue && executor . queue . remove ( this ) ) executor . maxQueueSizeConstraint . release ( ) ; if ( nsAcceptEnd == nsAcceptBegin - 1 ) // currently unset nsRunEnd = nsQueueEnd = nsAcceptEnd = System . nanoTime ( ) ; boolean aborted = result . compareAndSet ( state , cause ) ; if ( aborted ) try { state . releaseShared ( ABORTED ) ; if ( nsQueueEnd == nsAcceptBegin - 2 ) // currently unset nsRunEnd = nsQueueEnd = System . nanoTime ( ) ; if ( callback != null ) callback . onEnd ( task , this , null , true , 0 , cause ) ; } finally { if ( latch != null ) latch . countDown ( ) ; if ( cancellableStage != null ) { if ( TraceComponent . isAnyTracingEnabled ( ) && tc . isDebugEnabled ( ) ) Tr . debug ( this , tc , "completion stage to complete exceptionally: " + cancellableStage ) ; cancellableStage . completeExceptionally ( cause ) ; } } else { // Prevent premature return from abort that would allow subsequent getState() to indicate // that the task is still in SUBMITTED state. while ( state . get ( ) < RUNNING ) Thread . yield ( ) ; } return aborted ; }
Invoked to abort a task .