/** * Sets the result. If {@code result} is an instance of Throwable, this * future will be completed exceptionally. That is, {@link #get} will throw * the exception rather than return it. * * @return true, if this call made this future to complete */ protected boolean setResult(Object result) { for (; ; ) { Object currentState = this.state; if (isDoneState(currentState)) { return false; } if (STATE.compareAndSet(this, currentState, result)) { done(); notifyThreadsWaitingOnGet(); runAsynchronous((ExecutionCallbackNode) currentState, result); break; } } return true; }
/** * Sets the result. If {@code result} is an instance of Throwable, this * future will be completed exceptionally. That is, {@link #get} will throw * the exception rather than return it. * * @return true, if this call made this future to complete */ protected boolean setResult(Object result) { for (; ; ) { Object currentState = this.state; if (isDoneState(currentState)) { return false; } if (STATE.compareAndSet(this, currentState, result)) { done(); notifyThreadsWaitingOnGet(); runAsynchronous((ExecutionCallbackNode) currentState, result); break; } } return true; }