本文整理了Java中java.util.concurrent.ScheduledThreadPoolExecutor.shutdownNow()
方法的一些代码示例,展示了ScheduledThreadPoolExecutor.shutdownNow()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。ScheduledThreadPoolExecutor.shutdownNow()
方法的具体详情如下:
包路径:java.util.concurrent.ScheduledThreadPoolExecutor
类名称:ScheduledThreadPoolExecutor
方法名:shutdownNow
[英]Attempts to stop all actively executing tasks, halts the processing of waiting tasks, and returns a list of the tasks that were awaiting execution.
This method does not wait for actively executing tasks to terminate. Use #awaitTermination to do that.
There are no guarantees beyond best-effort attempts to stop processing actively executing tasks. This implementation cancels tasks via Thread#interrupt, so any task that fails to respond to interrupts may never terminate.
[中]尝试停止所有正在执行的任务,停止正在等待的任务的处理,并返回正在等待执行的任务的列表。
此方法不会等待主动执行的任务终止。使用#等待终止来完成。
除了尽最大努力停止处理积极执行的任务之外,没有其他保证。此实现通过线程中断取消任务,因此任何未能响应中断的任务可能永远不会终止。
代码示例来源:origin: prestodb/presto
@PreDestroy
public void shutdown()
{
executor.shutdownNow();
}
代码示例来源:origin: apache/incubator-gobblin
@Override
public void stop() {
this.flagFlippingExecutor.shutdownNow();
}
}
代码示例来源:origin: apache/geode
/**
* Stops query monitoring. Makes this {@link QueryMonitor} unusable for further monitoring.
*/
public void stopMonitoring() {
executor.shutdownNow();
}
代码示例来源:origin: apache/flink
@Override
protected void finalize() throws Throwable {
super.finalize();
timerService.shutdownNow();
}
代码示例来源:origin: ehcache/ehcache3
public void shutdownNow() {
scheduler.shutdownNow();
}
代码示例来源:origin: apache/flink
@Override
public void shutdownService() {
if (status.compareAndSet(STATUS_ALIVE, STATUS_SHUTDOWN) ||
status.compareAndSet(STATUS_QUIESCED, STATUS_SHUTDOWN)) {
timerService.shutdownNow();
}
}
代码示例来源:origin: netty/netty
@Override
public List<Runnable> shutdownNow() {
List<Runnable> tasks = super.shutdownNow();
terminationFuture.trySuccess(null);
return tasks;
}
代码示例来源:origin: redisson/redisson
@Override
public List<Runnable> shutdownNow() {
List<Runnable> tasks = super.shutdownNow();
terminationFuture.trySuccess(null);
return tasks;
}
代码示例来源:origin: apache/geode
/**
* Shutdown the executor immediately, returning a list of tasks that haven't been run. Like
* ScheduledThreadPoolExecutor, this returns a list of RunnableScheduledFuture objects, instead of
* the actual tasks submitted. However, these Future objects are even less useful than the ones
* returned by ScheduledThreadPoolExecutor. In particular, they don't match the future returned by
* the {{@link #submit(Runnable)} method, and the run method won't do anything useful. This list
* should only be used as a count of the number of tasks that didn't execute.
*
* @see ScheduledThreadPoolExecutor#shutdownNow()
*/
@Override
public List shutdownNow() {
List tasks = timer.shutdownNow();
super.shutdownNow();
return tasks;
}
代码示例来源:origin: voldemort/voldemort
@Override
public void stopInner() {
this.scheduler.shutdownNow();
try {
this.scheduler.awaitTermination(5, TimeUnit.SECONDS);
} catch(Exception e) {
logger.info("Error waiting for termination of scheduler service", e);
}
}
代码示例来源:origin: wildfly/wildfly
@Override
public List<Runnable> shutdownNow() {
List<Runnable> tasks = super.shutdownNow();
terminationFuture.trySuccess(null);
return tasks;
}
代码示例来源:origin: kiegroup/jbpm
@Override
public void shutdown() {
try {
this.scheduler.shutdown();
if ( !this.scheduler.awaitTermination( 10, TimeUnit.SECONDS ) ) {
this.scheduler.shutdownNow();
}
} catch ( InterruptedException e ) {
this.scheduler.shutdownNow();
Thread.currentThread().interrupt();
}
this.activeTimer.clear();
}
代码示例来源:origin: kiegroup/jbpm
public static synchronized void dispose() {
try {
if (scheduler != null) {
scheduler.shutdownNow();
}
startScheduledTaskDeadlines.clear();
endScheduledTaskDeadlines.clear();
jobHandles.clear();
notificationListener = null;
TaskDeadlinesServiceImpl.instance = null;
} catch (Exception e) {
logger.error("Error encountered when disposing TaskDeadlineService", e);
}
}
}
代码示例来源:origin: apache/hbase
/**
* shutdown the service. Any chores that are scheduled for execution will be cancelled. Any chores
* in the middle of execution will be interrupted and shutdown. This service will be unusable
* after this method has been called (i.e. future scheduling attempts will fail).
*/
public synchronized void shutdown() {
scheduler.shutdownNow();
if (LOG.isInfoEnabled()) {
LOG.info("Chore service for: " + coreThreadPoolPrefix + " had " + scheduledChores.keySet()
+ " on shutdown");
}
cancelAllChores(true);
scheduledChores.clear();
choresMissingStartTime.clear();
}
代码示例来源:origin: apache/hive
public void close() {
memoryAndRowLogExecutor.shutdown();
memoryAndRowLogFuture.cancel(false);
try {
if (!memoryAndRowLogExecutor.awaitTermination(5, TimeUnit.SECONDS)) {
memoryAndRowLogExecutor.shutdownNow();
}
} catch (InterruptedException e) {
memoryAndRowLogExecutor.shutdownNow();
Thread.currentThread().interrupt();
}
if (LOG.isInfoEnabled()) {
logMemoryInfo();
}
}
代码示例来源:origin: nutzam/nutz
/**
* 关闭定时任务服务
* <p>系统关闭时可调用此方法终止正在执行的定时任务,一旦关闭后不允许再向线程池中添加任务,否则会报RejectedExecutionException异常</p>
*/
public static void depose() {
int timerNum = timerList.size();
//清除Timer
synchronized (timerList) {
for (Timer t: timerList)
t.cancel();
timerList.clear();
}
List<Runnable> awaitingExecution = taskScheduler.shutdownNow();
logger.infof("Tasks stopping. Tasks awaiting execution: %d", timerNum + awaitingExecution.size());
}
代码示例来源:origin: PipelineAI/pipeline
/**
* Clears all listeners.
* <p>
* NOTE: This will result in race conditions if {@link #addTimerListener(com.netflix.hystrix.util.HystrixTimer.TimerListener)} is being concurrently called.
* </p>
*/
public static void reset() {
ScheduledExecutor ex = INSTANCE.executor.getAndSet(null);
if (ex != null && ex.getThreadPool() != null) {
ex.getThreadPool().shutdownNow();
}
}
代码示例来源:origin: apache/nifi
@OnStopped
public void tearDown() throws ProcessException {
for (ReceivingClient client : this.liveTcpClients.values()) {
try {
client.stop();
} catch (Exception e) {
this.getLogger().warn("Failure while stopping client '" + client + "'", e);
}
}
this.liveTcpClients.clear();
this.clientScheduler.shutdown();
try {
if (!this.clientScheduler.awaitTermination(10000, TimeUnit.MILLISECONDS)) {
this.getLogger().info("Failed to stop client scheduler in 10 sec. Terminating");
this.clientScheduler.shutdownNow();
}
} catch (InterruptedException e) {
Thread.currentThread().interrupt();
}
this.getLogger().info("Processor has successfully shut down");
}
代码示例来源:origin: rapidoid/rapidoid
public synchronized void shutdownNow() {
active.set(false);
if (executor.isInitialized()) {
Opt<ThreadPoolExecutor> exe = executor();
if (exe.exists()) {
exe.get().shutdownNow();
Jobs.awaitTermination(exe.get());
}
}
if (scheduler.isInitialized()) {
Opt<ScheduledThreadPoolExecutor> sch = scheduler();
if (sch.exists()) {
sch.get().shutdownNow();
Jobs.awaitTermination(sch.get());
}
}
}
代码示例来源:origin: jMonkeyEngine/jmonkeyengine
@Override
public void done(Integer result) {
if (globalListener != null) {
if (result < 6) {
globalListener.step("Prefiltered env map face " + result + " generated");
} else {
globalListener.step("Irradiance map generated");
}
}
jobState.done[index] = true;
if (jobState.isDone()) {
probe.setNbMipMaps(probe.getPrefilteredEnvMap().getImage().getMipMapSizes().length);
probe.setReady(true);
if (globalListener != null) {
globalListener.done(probe);
}
jobState.executor.shutdownNow();
}
}
}
内容来源于网络,如有侵权,请联系作者删除!