mirror of
https://github.com/corda/corda.git
synced 2025-01-07 13:38:47 +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
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
// must set running thread before we change the state for cancel to work
|
if (currentState.compareAndSet(State.New, State.Running)) {
|
||||||
runningThread = Thread.currentThread();
|
runningThread = Thread.currentThread();
|
||||||
try {
|
try {
|
||||||
if (currentState.compareAndSet(State.New, State.Running)) {
|
result = callable.call();
|
||||||
try {
|
} catch (Throwable t) {
|
||||||
result = callable.call();
|
failure = t;
|
||||||
} catch (Throwable t) {
|
} finally {
|
||||||
failure = t;
|
currentState.compareAndSet(State.Running, State.Done);
|
||||||
} finally {
|
handleDone();
|
||||||
currentState.compareAndSet(State.Running, State.Done);
|
runningThread = null; // must be set after state changed to done
|
||||||
handleDone();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
} finally {
|
|
||||||
runningThread = null;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user