MCPcopy Create free account
hub / github.com/ReadyTalk/avian / cancel

Method cancel

classpath/java/util/concurrent/FutureTask.java:93–116  ·  view source on GitHub ↗
(boolean mayInterruptIfRunning)

Source from the content-addressed store, hash-verified

91 }
92
93 @Override
94 public boolean cancel(boolean mayInterruptIfRunning) {
95 if (currentState.compareAndSet(State.New, State.Canceled)) {
96 handleDone();
97
98 return true;
99 } else if (mayInterruptIfRunning &&
100 currentState.compareAndSet(State.Running, State.Canceling)) {
101 // handleDone will be called from running thread
102 try {
103 Thread runningThread = this.runningThread;
104 if (runningThread != null) {
105 runningThread.interrupt();
106
107 return true;
108 }
109 } finally {
110 // we can not set to canceled until interrupt status has been set
111 currentState.set(State.Canceled);
112 }
113 }
114
115 return false;
116 }
117
118 @Override
119 public boolean isCancelled() {

Callers

nothing calls this directly

Calls 4

handleDoneMethod · 0.95
interruptMethod · 0.95
setMethod · 0.65
compareAndSetMethod · 0.45

Tested by

no test coverage detected