Java Code Examples for org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor#setDaemon()

The following examples show how to use org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor#setDaemon() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: Web3SDKConnector.java    From WeEvent with Apache License 2.0 6 votes vote down vote up
public static ThreadPoolTaskExecutor initThreadPool(int core, int max, int keepalive) {
    // init thread pool
    ThreadPoolTaskExecutor pool = new ThreadPoolTaskExecutor();
    pool.setThreadNamePrefix("web3sdk-");
    pool.setCorePoolSize(core);
    pool.setMaxPoolSize(max);
    // queue conflict with thread pool scale up, forbid it
    pool.setQueueCapacity(0);
    pool.setKeepAliveSeconds(keepalive);
    // abort policy
    pool.setRejectedExecutionHandler(null);
    pool.setDaemon(true);
    pool.initialize();

    log.info("init ThreadPoolTaskExecutor");
    return pool;
}
 
Example 2
Source File: AMOPChannel.java    From WeEvent with Apache License 2.0 6 votes vote down vote up
private ThreadPoolTaskExecutor initThreadPool(int core, int keepalive) {
    // init thread pool
    ThreadPoolTaskExecutor pool = new ThreadPoolTaskExecutor();
    pool.setThreadNamePrefix("ftp service-");
    pool.setCorePoolSize(core);
    // queue conflict with thread pool scale up, forbid it
    pool.setQueueCapacity(0);
    pool.setKeepAliveSeconds(keepalive);
    // abort policy
    pool.setRejectedExecutionHandler(null);
    pool.setDaemon(true);
    pool.initialize();

    log.info("init ThreadPoolTaskExecutor");
    return pool;
}
 
Example 3
Source File: RTMPConnManager.java    From red5-client with Apache License 2.0 6 votes vote down vote up
/**
 * Creates a connection instance based on the supplied type.
 * 
 * @param cls class
 * @return connection
 * @throws Exception thrown
 */
public RTMPConnection createConnectionInstance(Class<?> cls) throws Exception {
    RTMPConnection conn = null;
    if (cls == RTMPMinaConnection.class) {
        conn = (RTMPMinaConnection) cls.getDeclaredConstructor().newInstance();
    } else if (cls == RTMPTClientConnection.class) {
        conn = (RTMPTClientConnection) cls.getDeclaredConstructor().newInstance();
    } else {
        conn = (RTMPConnection) cls.getDeclaredConstructor().newInstance();
    }
    conn.setMaxHandshakeTimeout(maxHandshakeTimeout);
    conn.setMaxInactivity(maxInactivity);
    conn.setPingInterval(pingInterval);
    if (enableTaskExecutor) {
        // setup executor
        ThreadPoolTaskExecutor executor = new ThreadPoolTaskExecutor();
        executor.setCorePoolSize(1);
        executor.setDaemon(true);
        executor.setMaxPoolSize(1);
        executor.setQueueCapacity(executorQueueCapacity);
        executor.initialize();
        conn.setExecutor(executor);
    }
    return conn;
}
 
Example 4
Source File: BrokerApplication.java    From WeEvent with Apache License 2.0 5 votes vote down vote up
@Bean
public Executor taskExecutor() {
    ThreadPoolTaskExecutor pool = new ThreadPoolTaskExecutor();
    pool.setThreadNamePrefix("weevent-executor-");
    // run in thread immediately, no blocking queue
    pool.setQueueCapacity(0);
    pool.setDaemon(true);
    pool.initialize();

    log.info("init daemon thread pool");
    return pool;
}
 
Example 5
Source File: ProcessorApplication.java    From WeEvent with Apache License 2.0 5 votes vote down vote up
@Bean(name = "processor_daemon_task_executor")
public static ThreadPoolTaskExecutor getThreadPoolTaskExecutor() {
    ThreadPoolTaskExecutor pool = new ThreadPoolTaskExecutor();
    pool.setThreadNamePrefix("processor_daemon_");
    // run in thread immediately, no blocking queue
    pool.setQueueCapacity(0);
    pool.setDaemon(true);
    pool.initialize();

    log.info("init processor daemon thread pool");
    return pool;
}
 
Example 6
Source File: ThreadHelper.java    From flow-platform-x with Apache License 2.0 5 votes vote down vote up
public static ThreadPoolTaskExecutor createTaskExecutor(int maxPoolSize,
                                                        int corePoolSize,
                                                        int queueSize,
                                                        String threadNamePrefix) {
    ThreadPoolTaskExecutor taskExecutor = new ThreadPoolTaskExecutor();
    taskExecutor.setCorePoolSize(corePoolSize);
    taskExecutor.setMaxPoolSize(maxPoolSize);
    taskExecutor.setQueueCapacity(queueSize);
    taskExecutor.setThreadNamePrefix(threadNamePrefix);
    taskExecutor.setDaemon(true);

    taskExecutor.initialize();
    return taskExecutor;
}
 
Example 7
Source File: ThreadHelper.java    From flow-platform-x with Apache License 2.0 5 votes vote down vote up
public static ThreadPoolTaskExecutor createTaskExecutor(int maxPoolSize,
                                                        int corePoolSize,
                                                        int queueSize,
                                                        String threadNamePrefix) {
    ThreadPoolTaskExecutor taskExecutor = new ThreadPoolTaskExecutor();
    taskExecutor.setCorePoolSize(corePoolSize);
    taskExecutor.setMaxPoolSize(maxPoolSize);
    taskExecutor.setQueueCapacity(queueSize);
    taskExecutor.setThreadNamePrefix(threadNamePrefix);
    taskExecutor.setDaemon(true);

    taskExecutor.initialize();
    return taskExecutor;
}
 
Example 8
Source File: GcpPubSubAutoConfiguration.java    From spring-cloud-gcp with Apache License 2.0 5 votes vote down vote up
@Bean
@ConditionalOnMissingBean(name = "pubSubAcknowledgementExecutor")
public Executor pubSubAcknowledgementExecutor() {
	ThreadPoolTaskExecutor ackExecutor = new ThreadPoolTaskExecutor();
	ackExecutor.setMaxPoolSize(this.gcpPubSubProperties.getSubscriber().getMaxAcknowledgementThreads());
	ackExecutor.setThreadNamePrefix("gcp-pubsub-ack-executor");
	ackExecutor.setDaemon(true);
	return ackExecutor;
}
 
Example 9
Source File: CloudVisionAutoConfiguration.java    From spring-cloud-gcp with Apache License 2.0 5 votes vote down vote up
@Bean
@ConditionalOnMissingBean(name = "cloudVisionExecutor")
public Executor cloudVisionExecutor() {
	ThreadPoolTaskExecutor ackExecutor = new ThreadPoolTaskExecutor();
	ackExecutor.setMaxPoolSize(this.cloudVisionProperties.getExecutorThreadsCount());
	ackExecutor.setThreadNamePrefix("gcp-cloud-vision-ocr-executor");
	ackExecutor.setDaemon(true);
	return ackExecutor;
}
 
Example 10
Source File: SchedulingConfig.java    From NettyReverseProxy with Apache License 2.0 5 votes vote down vote up
@Bean(name = "taskExecutor")
public ThreadPoolTaskExecutor taskExecutor() {
    ThreadPoolTaskExecutor executor = new ThreadPoolTaskExecutor();
    executor.setCorePoolSize(5);
    executor.setMaxPoolSize(10);
    executor.setQueueCapacity(10);
    executor.setDaemon(true);
    executor.setThreadNamePrefix("taskExecutor-");
    return executor;
}
 
Example 11
Source File: SchedulingConfig.java    From NettyReverseProxy with Apache License 2.0 5 votes vote down vote up
@Bean(name = "frontendWorkTaskExecutor")
public Executor createFrontendWorkTaskExecutor() {
    ThreadPoolTaskExecutor executor = new ThreadPoolTaskExecutor();
    executor.setCorePoolSize(1);
    executor.setMaxPoolSize(1);
    executor.setKeepAliveSeconds(0);
    executor.setQueueCapacity(0);
    executor.setDaemon(true);
    executor.setThreadNamePrefix("frontendWorkTaskExecutor-");
    return executor;
}
 
Example 12
Source File: PlowThreadPools.java    From plow with Apache License 2.0 5 votes vote down vote up
@Bean(name="nodeDispatchExecutor")
public ThreadPoolTaskExecutor nodeDispatcherExecutor() {
    ThreadPoolTaskExecutor t = new ThreadPoolTaskExecutor();
    t.setCorePoolSize(plowCfg.get("plow.dispatcher.node.threads", 4));
    t.setMaxPoolSize(plowCfg.get("plow.dispatcher.node.threads", 4));
    t.setThreadNamePrefix("nodeDispatchExecutor");
    t.setDaemon(false);
    t.setQueueCapacity(1000);
    return t;
}
 
Example 13
Source File: PlowThreadPools.java    From plow with Apache License 2.0 5 votes vote down vote up
@Bean(name="pipelineExecutor")
public ThreadPoolTaskExecutor pipelineExecutor() {
    ThreadPoolTaskExecutor t = new ThreadPoolTaskExecutor();
    t.setCorePoolSize(plowCfg.get("plow.dispatcher.pipeline.threads", 16));
    t.setMaxPoolSize(plowCfg.get("plow.dispatcher.pipeline.threads", 16));
    t.setThreadNamePrefix("pipelineExecutor");
    t.setDaemon(false);
    t.setQueueCapacity(5000);
    return t;
}
 
Example 14
Source File: PlowThreadPools.java    From plow with Apache License 2.0 5 votes vote down vote up
/**
 * Handles Async commands from the API.
 */
@Bean(name="stateChangeExecutor")
public ThreadPoolTaskExecutor stateChangeExecutor() {
    ThreadPoolTaskExecutor t = new ThreadPoolTaskExecutor();
    t.setCorePoolSize(8);
    t.setMaxPoolSize(16);
    t.setThreadNamePrefix("StateChange");
    t.setDaemon(false);
    t.setQueueCapacity(1000);
    t.setRejectedExecutionHandler(new ThreadPoolExecutor.CallerRunsPolicy());
    return t;
}
 
Example 15
Source File: PlowThreadPools.java    From plow with Apache License 2.0 5 votes vote down vote up
/**
 * Handles communication with RNDaemon.
 */
@Bean(name="rndCommandExecutor")
public ThreadPoolTaskExecutor rndCommandExecutor() {
    ThreadPoolTaskExecutor t = new ThreadPoolTaskExecutor();
    t.setCorePoolSize(plowCfg.get("plow.rndpool.cache.threads", 8));
    t.setMaxPoolSize(plowCfg.get("plow.rndpool.cache.threads", 8));
    t.setThreadNamePrefix("RndRun");
    t.setDaemon(false);
    t.setQueueCapacity(1000);
    t.setRejectedExecutionHandler(new ThreadPoolExecutor.CallerRunsPolicy());
    return t;
}