Example usage for org.springframework.scheduling.concurrent ConcurrentTaskScheduler ConcurrentTaskScheduler

List of usage examples for org.springframework.scheduling.concurrent ConcurrentTaskScheduler ConcurrentTaskScheduler

Introduction

In this page you can find the example usage for org.springframework.scheduling.concurrent ConcurrentTaskScheduler ConcurrentTaskScheduler.

Prototype

public ConcurrentTaskScheduler(ScheduledExecutorService scheduledExecutor) 

Source Link

Document

Create a new ConcurrentTaskScheduler, using the given java.util.concurrent.ScheduledExecutorService as shared delegate.

Usage

From source file:org.zalando.spring.boot.scheduling.CustomSchedulingConfiguration.java

@Override
public void configureTasks(ScheduledTaskRegistrar taskRegistrar) {
    if (properties.isEnabled()) {
        if (taskScheduler != null) {
            taskRegistrar.setScheduler(taskScheduler);
        } else {// ww  w . j  av a  2  s. c o  m
            throw new BeanCreationException("Expecting a 'ConcurrentTaskScheduler' injected, but was 'null'");
        }
    } else {
        log.info("'CustomSchedulingConfiguration' is disabled, create a default - 'ConcurrentTaskScheduler'");
        this.localExecutor = Executors.newSingleThreadScheduledExecutor();
        taskRegistrar.setScheduler(new ConcurrentTaskScheduler(localExecutor));
    }
}

From source file:com.github.mrstampy.gameboot.concurrent.GameBootConcurrentConfiguration.java

/**
 * Task scheduler.//from   w w  w.j  a  va2 s  . c om
 *
 * @return the task scheduler
 */
@Bean(name = GAME_BOOT_TASK_SCHEDULER)
public TaskScheduler taskScheduler() {
    String name = isEmpty(taskSchedulerName) ? "GameBoot Task Scheduler" : taskSchedulerName;

    GameBootThreadFactory factory = new GameBootThreadFactory(name);

    ScheduledExecutorService exe = Executors.newScheduledThreadPool(taskSchedulerPoolSize, factory);

    return new ConcurrentTaskScheduler(exe);
}