public void cancel(boolean force)
{
Preconditions.checkState(!Thread.holdsLock(this), "Can not cancel while holding a lock on this");
try (SetThreadName setThreadName = new SetThreadName("Stage-%s", stageId)) {
// before canceling the task wait to see if it finishes normally
if (!force) {
Duration waitTime = new Duration(100, MILLISECONDS);
for (RemoteTask remoteTask : tasks.values()) {
try {