public final void cancel ( CancelException reason ) { if ( cancelling != null ) return ; if ( reason == null ) reason = new CancelException ( "No reason given" ) ; cancelling = reason ; if ( TaskScheduler . cancel ( this ) ) { status = Task . STATUS_DONE ; result . cancelled ( reason ) ; return ; } if ( manager . remove ( this ) ) { status = Task . STATUS_DONE ; result . cancelled ( reason ) ; return ; } if ( status == Task . STATUS_NOT_STARTED ) { status = Task . STATUS_DONE ; result . cancelled ( reason ) ; return ; } }
Cancel this task .