本文整理了Java中java.util.concurrent.ScheduledThreadPoolExecutor.allowCoreThreadTimeOut()
方法的一些代码示例,展示了ScheduledThreadPoolExecutor.allowCoreThreadTimeOut()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。ScheduledThreadPoolExecutor.allowCoreThreadTimeOut()
方法的具体详情如下:
包路径:java.util.concurrent.ScheduledThreadPoolExecutor
类名称:ScheduledThreadPoolExecutor
方法名:allowCoreThreadTimeOut
暂无
代码示例来源:origin: wildfly/wildfly
public void setKeepAliveTime(final long milliseconds) {
super.setKeepAliveTime(milliseconds, TimeUnit.MILLISECONDS);
super.allowCoreThreadTimeOut(milliseconds < Long.MAX_VALUE);
}
代码示例来源:origin: wildfly/wildfly
public void setKeepAliveTime(final long time, final TimeUnit unit) {
super.setKeepAliveTime(time, unit);
super.allowCoreThreadTimeOut(time < Long.MAX_VALUE);
}
代码示例来源:origin: spotify/helios
public TaskMonitor(final JobId jobId, final FlapController flapController,
final StatusUpdater statusUpdater) {
this.jobId = jobId;
this.flapController = flapController;
this.statusUpdater = statusUpdater;
final ScheduledThreadPoolExecutor executor = new ScheduledThreadPoolExecutor(1);
// Let core threads time out to avoid unnecessarily keeping a flapping state check thread alive
// for the majority of tasks that do not flap.
executor.setKeepAliveTime(5, SECONDS);
executor.allowCoreThreadTimeOut(true);
this.scheduler = MoreExecutors.getExitingScheduledExecutorService(executor, 0, SECONDS);
}
代码示例来源:origin: googleapis/google-cloud-java
@Override
public ScheduledExecutorService create() {
ScheduledThreadPoolExecutor service = new ScheduledThreadPoolExecutor(8);
service.setKeepAliveTime(5, TimeUnit.SECONDS);
service.allowCoreThreadTimeOut(true);
service.setRemoveOnCancelPolicy(true);
return service;
}
代码示例来源:origin: aws/aws-sdk-java
/**
* Creates a {@link ScheduledThreadPoolExecutor} with custom name for the threads.
*
* @param name the prefix to add to the thread name in ThreadFactory.
* @return The default thread pool for request timeout and client execution timeout features.
*/
public static ScheduledThreadPoolExecutor buildDefaultTimeoutThreadPool(final String name) {
ScheduledThreadPoolExecutor executor = new ScheduledThreadPoolExecutor(5, getThreadFactory(name));
safeSetRemoveOnCancel(executor);
executor.setKeepAliveTime(5, TimeUnit.SECONDS);
executor.allowCoreThreadTimeOut(true);
return executor;
}
代码示例来源:origin: apache/nifi
@OnScheduled
public void onScheduled(final ProcessContext context) throws ProcessException {
this.receiveBufferSize = context.getProperty(RECEIVE_BUFFER_SIZE).asDataSize(DataUnit.B).intValue();
this.originalServerAddressList = context.getProperty(ENDPOINT_LIST).getValue();
this.endOfMessageByte = ((byte) context.getProperty(END_OF_MESSAGE_BYTE).asInteger().intValue());
this.connectionAttemptCount = context.getProperty(CONNECTION_ATTEMPT_COUNT).asInteger();
this.reconnectInterval = context.getProperty(RECONNECT_INTERVAL).asTimePeriod(TimeUnit.MILLISECONDS);
this.clientScheduler = new ScheduledThreadPoolExecutor(originalServerAddressList.split(",").length + 1);
this.clientScheduler.setKeepAliveTime(10, TimeUnit.SECONDS);
this.clientScheduler.allowCoreThreadTimeOut(true);
for (final Map.Entry<PropertyDescriptor, String> entry : context.getProperties().entrySet()) {
final PropertyDescriptor descriptor = entry.getKey();
if (descriptor.isDynamic()) {
this.dynamicAttributes.put(descriptor.getName(), entry.getValue());
}
}
}
代码示例来源:origin: com.amazonaws/aws-java-sdk-core
/**
* Creates a {@link ScheduledThreadPoolExecutor} with custom name for the threads.
*
* @param name the prefix to add to the thread name in ThreadFactory.
* @return The default thread pool for request timeout and client execution timeout features.
*/
public static ScheduledThreadPoolExecutor buildDefaultTimeoutThreadPool(final String name) {
ScheduledThreadPoolExecutor executor = new ScheduledThreadPoolExecutor(5, getThreadFactory(name));
safeSetRemoveOnCancel(executor);
executor.setKeepAliveTime(5, TimeUnit.SECONDS);
executor.allowCoreThreadTimeOut(true);
return executor;
}
代码示例来源:origin: DV8FromTheWorld/JDA
private void shutdownPools()
{
if (audioLifeCyclePool != null)
audioLifeCyclePool.shutdownNow();
if (shutdownGatewayPool)
getGatewayPool().shutdown();
if (shutdownCallbackPool)
getCallbackPool().shutdown();
if (shutdownRateLimitPool)
{
ScheduledExecutorService rateLimitPool = getRateLimitPool();
if (rateLimitPool instanceof ScheduledThreadPoolExecutor)
{
ScheduledThreadPoolExecutor executor = (ScheduledThreadPoolExecutor) rateLimitPool;
executor.setKeepAliveTime(5L, TimeUnit.SECONDS);
executor.allowCoreThreadTimeOut(true);
}
else
{
rateLimitPool.shutdown();
}
}
}
代码示例来源:origin: ch.cmbntr/modulizer-bootstrap
private static ScheduledThreadPoolExecutor buildBlockableExecutor() {
final ScheduledThreadPoolExecutor stpe = new ScheduledThreadPoolExecutor(POOL_SIZE, THREAD_FACTORY);
stpe.setKeepAliveTime(15L, TimeUnit.SECONDS);
stpe.allowCoreThreadTimeOut(true);
return stpe;
}
代码示例来源:origin: org.jboss.eap/wildfly-client-all
public void setKeepAliveTime(final long time, final TimeUnit unit) {
super.setKeepAliveTime(time, unit);
super.allowCoreThreadTimeOut(time < Long.MAX_VALUE);
}
代码示例来源:origin: org.jboss.threads/jboss-threads
public void setKeepAliveTime(final long milliseconds) {
super.setKeepAliveTime(milliseconds, TimeUnit.MILLISECONDS);
super.allowCoreThreadTimeOut(milliseconds < Long.MAX_VALUE);
}
代码示例来源:origin: net.oneandone.reactive/reactive-http
private static ScheduledThreadPoolExecutor newScheduledThreadPoolExecutor() {
ScheduledThreadPoolExecutor executor = new ScheduledThreadPoolExecutor(0);
executor.setKeepAliveTime(DEFAULT_KEEP_ALIVE_PERIOD_SEC * 2, TimeUnit.SECONDS);
executor.allowCoreThreadTimeOut(true);
return executor;
}
代码示例来源:origin: io.snamp.instrumentation/core
private synchronized ScheduledExecutorService getScheduler(){
if(scheduler == null) {
final ScheduledThreadPoolExecutor executor;
final int corePoolSize = Math.max(1, Runtime.getRuntime().availableProcessors() / 2);
scheduler = executor = new ScheduledThreadPoolExecutor(corePoolSize, createThreadFactory(name));
executor.setKeepAliveTime(1, TimeUnit.MINUTES);
executor.allowCoreThreadTimeOut(true);
}
return scheduler;
}
代码示例来源:origin: at.molindo/helios-services
public TaskMonitor(final JobId jobId, final FlapController flapController,
final StatusUpdater statusUpdater) {
this.jobId = jobId;
this.flapController = flapController;
this.statusUpdater = statusUpdater;
final ScheduledThreadPoolExecutor executor = new ScheduledThreadPoolExecutor(1);
// Let core threads time out to avoid unnecessarily keeping a flapping state check thread alive
// for the majority of tasks that do not flap.
executor.setKeepAliveTime(5, SECONDS);
executor.allowCoreThreadTimeOut(true);
this.scheduler = MoreExecutors.getExitingScheduledExecutorService(executor, 0, SECONDS);
}
代码示例来源:origin: io.joynr.java.core/libjoynr
@Inject
public DefaultScheduledExecutorServiceProvider(@Named(ConfigurableMessagingSettings.PROPERTY_MESSAGING_MAXIMUM_PARALLEL_SENDS) int maximumParallelSends,
ShutdownNotifier shutdownNotifier) {
ThreadFactory schedulerNamedThreadFactory = new JoynrThreadFactory("ScheduledExecutorService", true);
scheduler = new ScheduledThreadPoolExecutor(maximumParallelSends + MAX_SKELETON_THREADS + MQTT_THREADS,
schedulerNamedThreadFactory);
scheduler.setKeepAliveTime(100, TimeUnit.SECONDS);
scheduler.allowCoreThreadTimeOut(true);
shutdownNotifier.registerToBeShutdownAsLast(this);
}
代码示例来源:origin: com.google.cloud/google-cloud-core-grpc
@Override
public ScheduledExecutorService create() {
ScheduledThreadPoolExecutor service = new ScheduledThreadPoolExecutor(8);
service.setKeepAliveTime(5, TimeUnit.SECONDS);
service.allowCoreThreadTimeOut(true);
service.setRemoveOnCancelPolicy(true);
return service;
}
代码示例来源:origin: org.opendaylight.infrautils/async-impl
public static ScheduledThreadPoolExecutor create(String poolName, int corePoolSize, long keepAliveTime,
TimeUnit keepAliveUnit) {
ScheduledThreadPoolExecutor executor = create(poolName, corePoolSize);
executor.allowCoreThreadTimeOut(true);
executor.setKeepAliveTime(keepAliveTime, keepAliveUnit);
return executor;
}
}
代码示例来源:origin: apache/ofbiz-framework
public static ScheduledExecutorService getScheduledExecutor(ThreadGroup group, String namePrefix, int threadCount, long keepAliveSeconds, boolean preStart) {
ScheduledThreadPoolExecutor executor = new ScheduledThreadPoolExecutor(threadCount, new ExecutionPoolThreadFactory(group, namePrefix));
if (keepAliveSeconds > 0) {
executor.setKeepAliveTime(keepAliveSeconds, TimeUnit.SECONDS);
executor.allowCoreThreadTimeOut(true);
}
if (preStart) {
executor.prestartAllCoreThreads();
}
return executor;
}
代码示例来源:origin: com.github.mcpat.libxjava/libxjava-jse5
public ScheduledTaskExecutor(int initialPoolSize, int maxPoolSize, long keepAliveTimeInMillis, IThreadFactory threadFactory) {
_executorImpl= new ScheduledThreadPoolExecutorExtender(maxPoolSize, threadFactory);
_executorImpl.setKeepAliveTime(keepAliveTimeInMillis, TimeUnit.MILLISECONDS);
_executorImpl.allowCoreThreadTimeOut(true);
for(int i= 0; i < initialPoolSize; i++) {
_executorImpl.prestartCoreThread();
}
}
代码示例来源:origin: org.mule/mule-core
protected ScheduledExecutorService createScheduler()
{
ThreadFactory threadFactory = new NamedThreadFactory(this.getName() + ".scheduler");
ScheduledThreadPoolExecutor newExecutor = new ScheduledThreadPoolExecutor(4, threadFactory);
newExecutor.setExecuteExistingDelayedTasksAfterShutdownPolicy(false);
newExecutor.setKeepAliveTime(this.getReceiverThreadingProfile().getThreadTTL(), TimeUnit.MILLISECONDS);
newExecutor.allowCoreThreadTimeOut(true);
return newExecutor;
}
内容来源于网络,如有侵权,请联系作者删除!