protected fun runAndReset(): Boolean { if (state !== NEW || !UNSAFE.compareAndSwapObject( this, runnerOffset, null,Thread.currentThread()  ) ) return false var ran = false var s: Int = state try { val c: Callable<V> = callable if (c != null && s == NEW) { try { c.call() ran = true } catch (ex: Throwable) { setException(ex) } } } finally { runner = null s = state if (s >= INTERRUPTING) handlePossibleCancellationInterrupt(s) } return ran && s == NEW }
Executes the computation without setting its result , and then resets this future to initial state , failing to do so if the computation encounters an exception or is cancelled . This is designed for use with tasks that intrinsically execute more than once .