mirror of
https://github.com/corda/corda.git
synced 2025-01-05 20:54:13 +00:00
Changes so that we only set the running thread if we actually ARE the running thread
This commit is contained in:
parent
83a31314e0
commit
d56087240d
@ -34,21 +34,17 @@ public class FutureTask<T> implements RunnableFuture<T> {
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
// must set running thread before we change the state for cancel to work
|
||||
runningThread = Thread.currentThread();
|
||||
try {
|
||||
if (currentState.compareAndSet(State.New, State.Running)) {
|
||||
try {
|
||||
result = callable.call();
|
||||
} catch (Throwable t) {
|
||||
failure = t;
|
||||
} finally {
|
||||
currentState.compareAndSet(State.Running, State.Done);
|
||||
handleDone();
|
||||
}
|
||||
if (currentState.compareAndSet(State.New, State.Running)) {
|
||||
runningThread = Thread.currentThread();
|
||||
try {
|
||||
result = callable.call();
|
||||
} catch (Throwable t) {
|
||||
failure = t;
|
||||
} finally {
|
||||
currentState.compareAndSet(State.Running, State.Done);
|
||||
handleDone();
|
||||
runningThread = null; // must be set after state changed to done
|
||||
}
|
||||
} finally {
|
||||
runningThread = null;
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user