java.util.concurrent.FutureTask.cancel()方法的使用及代码示例

x33g5p2x  于2022-01-18 转载在 其他  
字(4.9k)|赞(0)|评价(0)|浏览(246)

本文整理了Java中java.util.concurrent.FutureTask.cancel()方法的一些代码示例,展示了FutureTask.cancel()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。FutureTask.cancel()方法的具体详情如下:
包路径:java.util.concurrent.FutureTask
类名称:FutureTask
方法名:cancel

FutureTask.cancel介绍

暂无

代码示例

代码示例来源:origin: skylot/jadx

@Override
  public boolean cancel(boolean mayInterruptIfRunning) {
    executor.shutdownNow();
    return super.cancel(mayInterruptIfRunning);
  }
}

代码示例来源:origin: ReactiveX/RxJava

@Override
  public boolean cancel(boolean mayInterruptIfRunning) {
    interrupted[0] = mayInterruptIfRunning;
    return super.cancel(mayInterruptIfRunning);
  }
};

代码示例来源:origin: ReactiveX/RxJava

@Override
  public boolean cancel(boolean mayInterruptIfRunning) {
    interrupted[0] = mayInterruptIfRunning;
    return super.cancel(mayInterruptIfRunning);
  }
};

代码示例来源:origin: ReactiveX/RxJava

@Override
  public boolean cancel(boolean mayInterruptIfRunning) {
    interrupted[0] = mayInterruptIfRunning;
    return super.cancel(mayInterruptIfRunning);
  }
};

代码示例来源:origin: ReactiveX/RxJava

@Override
  public boolean cancel(boolean mayInterruptIfRunning) {
    interrupted[0] = mayInterruptIfRunning;
    return super.cancel(mayInterruptIfRunning);
  }
};

代码示例来源:origin: ReactiveX/RxJava

@Override
  public boolean cancel(boolean mayInterruptIfRunning) {
    interrupted[0] = mayInterruptIfRunning;
    return super.cancel(mayInterruptIfRunning);
  }
};

代码示例来源:origin: ReactiveX/RxJava

@Override
  public boolean cancel(boolean mayInterruptIfRunning) {
    interrupted[0] = mayInterruptIfRunning;
    return super.cancel(mayInterruptIfRunning);
  }
};

代码示例来源:origin: ReactiveX/RxJava

@Override
  public boolean cancel(boolean mayInterruptIfRunning) {
    interrupted[0] = mayInterruptIfRunning;
    return super.cancel(mayInterruptIfRunning);
  }
};

代码示例来源:origin: JZ-Darkal/AndroidHttpCapture

public final boolean cancel(boolean mayInterruptIfRunning) {
return mFuture.cancel(mayInterruptIfRunning);
}

代码示例来源:origin: spring-projects/spring-framework

@Override
public boolean cancel(boolean mayInterruptIfRunning) {
  boolean result = super.cancel(mayInterruptIfRunning);
  if (this.timer != null) {
    this.timer.cancel();
  }
  this.cancelled = true;
  return result;
}

代码示例来源:origin: apache/geode

@Override
public boolean cancel(boolean mayInterruptIfRunning) {
 delegate.cancel(true);
 return super.cancel(mayInterruptIfRunning);
}

代码示例来源:origin: robolectric/robolectric

@Implementation
protected boolean cancel(boolean mayInterruptIfRunning) {
 return future.cancel(mayInterruptIfRunning);
}

代码示例来源:origin: PipelineAI/pipeline

@Override
public void unsubscribe() {
  executor.remove(f);
  if (shouldInterruptThread.call()) {
    f.cancel(true);
  } else {
    f.cancel(false);
  }
}

代码示例来源:origin: LeonardoZ/java-concurrency-patterns

public <T> boolean cancel(List<FutureTask<T>> task) {
  boolean hasAFalse = task.stream().map(f -> f.cancel(true)).anyMatch(b -> b.equals(false));
  return !hasAFalse;
}

代码示例来源:origin: org.springframework/spring-context-support

@Override
public boolean cancel(boolean mayInterruptIfRunning) {
  boolean result = super.cancel(mayInterruptIfRunning);
  if (this.timer != null) {
    this.timer.cancel();
  }
  this.cancelled = true;
  return result;
}

代码示例来源:origin: robovm/robovm

public boolean cancel(boolean mayInterruptIfRunning) {
  boolean cancelled = super.cancel(mayInterruptIfRunning);
  if (cancelled && removeOnCancel && heapIndex >= 0)
    remove(this);
  return cancelled;
}

代码示例来源:origin: MovingBlocks/Terasology

/**
 * @param operation the operation to run - the executing thread will be interrupted when the operation is cancelled
 * @param canBeCancelled true if the operation is aborted when the {@link Thread#isInterrupted()} flag is set
 * @throws NullPointerException if operation is null
 * @throws IllegalArgumentException if startOperation() was called before
 */
public void startOperation(Callable<T> operation, boolean canBeCancelled) {
  Preconditions.checkState(parallelTask == null, "startOperation() cannot be called twice");
  cancelButton.setVisible(canBeCancelled);
  parallelTask = new FutureTask<>(operation);
  thread = new Thread(parallelTask, "Parallel Operation");
  thread.start();
  WidgetUtil.trySubscribe(this, "cancel", button -> parallelTask.cancel(true));
}

代码示例来源:origin: org.netbeans.api/org-openide-util

@Override
public boolean cancel(boolean mayInterruptIfRunning) {
  boolean result = cancellable == null ? true : cancellable.cancel();
  if (result) {
    boolean taskCancelled = task.cancel();
    boolean superCancel = super.cancel(mayInterruptIfRunning); //must call both!
    result = taskCancelled && superCancel;
  }
  return result;
}

代码示例来源:origin: apache/hbase

futureTask.cancel(true);
} finally {
 executor.shutdownNow();

代码示例来源:origin: apache/incubator-gobblin

@Override public boolean cancel(boolean mayInterruptIfRunning) {
 // FIXME there is a race condition here as the job may complete successfully before we
 // call cancelJob() below. There isn't an easy way to fix that right now.
 RunningState runState = fetchRunningState();
 if (runState.isCancelled()) {
  return true;
 }
 else if (runState.isDone()) {
  return false;
 }
 try {
  // No special processing of callbacks necessary
  getLegacyLauncher().cancelJob(new AbstractJobListener(){});
 } catch (JobException e) {
  throw new RuntimeException("Unable to cancel job " + _jobSpec + ": " + e, e);
 }
 return super.cancel(mayInterruptIfRunning);
}

相关文章