Close

Spring Framework - @Scheduled and @EnableScheduling Examples

[Last Updated: Nov 8, 2025]

Spring Framework 

This example shows how to schedule one time task, which doesn't to repeat periodically.

package com.logicbig.example;

import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;

import java.time.LocalTime;

@Component
public class MyBean {

@Scheduled(initialDelay = 1000)
public void runTask() {
System.out.printf("Running scheduled task " +
" thread: %s, time: %s%n",
Thread.currentThread().getName(),
LocalTime.now());


}
}

package com.logicbig.example;

import org.springframework.context.annotation.AnnotationConfigApplicationContext;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.scheduling.annotation.EnableScheduling;

@ComponentScan
@EnableScheduling
public class ScheduledExample {

public static void main(String[] args) throws InterruptedException {
AnnotationConfigApplicationContext context =
new AnnotationConfigApplicationContext(
ScheduledExample.class);

}

}

Output

Running scheduled task  thread: pool-1-thread-1, time: 16:21:04.298963700
Original Post




This example shows how to schedule a periodic task with a fixed delay.

package com.logicbig.example;

import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;

import java.time.LocalTime;

@Component
public class MyBean {

@Scheduled(initialDelay = 1000, fixedDelay = 1000)
public void runTask() {
System.out.printf("Running scheduled task " +
" thread: %s, time: %s%n",
Thread.currentThread().getName(),
LocalTime.now());
}

@Scheduled(initialDelay = 1000,
fixedDelayString = "2000")
public void runTask2() {
System.out.printf("Running scheduled task 2" +
" thread: %s, time: %s%n",
Thread.currentThread().getName(),
LocalTime.now());
}
}

package com.logicbig.example;

import org.springframework.context.annotation.AnnotationConfigApplicationContext;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.Configuration;
import org.springframework.scheduling.annotation.EnableScheduling;

@ComponentScan
@EnableScheduling
@Configuration
public class ScheduledExample {

public static void main(String[] args) throws InterruptedException {
AnnotationConfigApplicationContext context =
new AnnotationConfigApplicationContext(
ScheduledExample.class);

}

}

Output

Running scheduled task  thread: pool-1-thread-1, time: 16:21:19.109535400
Running scheduled task 2 thread: pool-1-thread-1, time: 16:21:19.110531900
Running scheduled task thread: pool-1-thread-1, time: 16:21:20.111538
Running scheduled task 2 thread: pool-1-thread-1, time: 16:21:21.111861600
Running scheduled task thread: pool-1-thread-1, time: 16:21:21.113261100
Running scheduled task thread: pool-1-thread-1, time: 16:21:22.118375900
Running scheduled task 2 thread: pool-1-thread-1, time: 16:21:23.116426400
Running scheduled task thread: pool-1-thread-1, time: 16:21:23.132031500
Running scheduled task thread: pool-1-thread-1, time: 16:21:24.144552200
Running scheduled task 2 thread: pool-1-thread-1, time: 16:21:25.133099900
Running scheduled task thread: pool-1-thread-1, time: 16:21:25.149102700
Running scheduled task thread: pool-1-thread-1, time: 16:21:26.158072
Running scheduled task 2 thread: pool-1-thread-1, time: 16:21:27.141515600
Running scheduled task thread: pool-1-thread-1, time: 16:21:27.172455200
.....................
Original Post




This example shows how to schedule a periodic task with a fixed rate.

package com.logicbig.example;

import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;

import java.time.LocalTime;

@Component
public class MyBean {

@Scheduled(initialDelay = 1000, fixedRate = 1000)
public void runTask() {
System.out.printf("Running scheduled task " +
" thread: %s, time: %s%n",
Thread.currentThread().getName(),
LocalTime.now());
}

@Scheduled(initialDelay = 1000,
fixedRateString = "2000")
public void runTask2() {
System.out.printf("Running scheduled task 2" +
" thread: %s, time: %s%n",
Thread.currentThread().getName(),
LocalTime.now());
}
}

package com.logicbig.example;

import org.springframework.context.annotation.AnnotationConfigApplicationContext;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.Configuration;
import org.springframework.scheduling.annotation.EnableScheduling;

@ComponentScan
@EnableScheduling
@Configuration
public class ScheduledExample {

public static void main(String[] args){
AnnotationConfigApplicationContext context =
new AnnotationConfigApplicationContext(
ScheduledExample.class);

}

}

Output

Running scheduled task  thread: pool-1-thread-1, time: 16:12:30.819769600
Running scheduled task 2 thread: pool-1-thread-1, time: 16:12:30.820770200
Running scheduled task thread: pool-1-thread-1, time: 16:12:31.812907700
Running scheduled task thread: pool-1-thread-1, time: 16:12:32.809861300
Running scheduled task 2 thread: pool-1-thread-1, time: 16:12:32.825956900
Running scheduled task thread: pool-1-thread-1, time: 16:12:33.822800300
Running scheduled task thread: pool-1-thread-1, time: 16:12:34.815637500
Running scheduled task 2 thread: pool-1-thread-1, time: 16:12:34.830898900
Running scheduled task thread: pool-1-thread-1, time: 16:12:35.817561600
Running scheduled task thread: pool-1-thread-1, time: 16:12:36.816961600
Running scheduled task 2 thread: pool-1-thread-1, time: 16:12:36.832602400
Running scheduled task thread: pool-1-thread-1, time: 16:12:37.823146200
Running scheduled task thread: pool-1-thread-1, time: 16:12:38.818677300
Running scheduled task 2 thread: pool-1-thread-1, time: 16:12:38.819673600
Running scheduled task thread: pool-1-thread-1, time: 16:12:39.833400500
.....................
Original Post




This example shows how to specify a custom TaskScheduler

package com.logicbig.example;

import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;

import java.time.LocalTime;

@Component
public class MyBean {

@Scheduled(fixedDelay = 1000)
public void runTask() {
System.out.printf("task thread: %s, time: %s%n",
Thread.currentThread().getName(),
LocalTime.now());
}

@Scheduled(fixedRate = 2000)
public void runTask2() {
System.out.printf("task 2 thread: %s, time: %s%n",
Thread.currentThread().getName(),
LocalTime.now());
}
}

package com.logicbig.example;

import org.springframework.context.annotation.AnnotationConfigApplicationContext;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.Configuration;
import org.springframework.scheduling.TaskScheduler;
import org.springframework.scheduling.annotation.EnableScheduling;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.scheduling.annotation.ScheduledAnnotationBeanPostProcessor;
import org.springframework.scheduling.concurrent.ConcurrentTaskExecutor;
import org.springframework.scheduling.concurrent.ConcurrentTaskScheduler;

import java.time.LocalTime;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;

@EnableScheduling
@ComponentScan
@Configuration
public class ScheduledOverrideDefaultExecutorExample {

@Bean
public TaskScheduler taskScheduler() {
return new ConcurrentTaskScheduler(
Executors.newScheduledThreadPool(3));
}

public static void main(String[] args) throws Exception {
AnnotationConfigApplicationContext context =
new AnnotationConfigApplicationContext(
ScheduledOverrideDefaultExecutorExample.class);

}
}

Output

task 2 thread: pool-1-thread-1, time: 16:12:11.066611600
task thread: pool-1-thread-2, time: 16:12:11.066611600
task thread: pool-1-thread-2, time: 16:12:12.068969300
task 2 thread: pool-1-thread-3, time: 16:12:13.066237600
task thread: pool-1-thread-1, time: 16:12:13.082184100
task thread: pool-1-thread-1, time: 16:12:14.098223600
task 2 thread: pool-1-thread-2, time: 16:12:15.066513400
task thread: pool-1-thread-3, time: 16:12:15.113458100
task thread: pool-1-thread-3, time: 16:12:16.120636300
task 2 thread: pool-1-thread-1, time: 16:12:17.066409600
task thread: pool-1-thread-2, time: 16:12:17.128454600
task thread: pool-1-thread-2, time: 16:12:18.134474700
task 2 thread: pool-1-thread-3, time: 16:12:19.070154200
task thread: pool-1-thread-1, time: 16:12:19.148299900
task thread: pool-1-thread-1, time: 16:12:20.156524500
.....................
Original Post

The return type on a method which is annotated with @Scheduled is ignored quietly. The older version (pre 4.3.0.RELEASE) will throw an exception.

package com.logicbig.example;

import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;

import java.time.LocalTime;

@Component
public class MyBean {

@Scheduled(fixedRate = 1000)
public String runTask() {
System.out.printf("task thread: %s, time: %s%n",
Thread.currentThread().getName(),
LocalTime.now());
try {
Thread.sleep(500);
} catch (InterruptedException e) {
}
return "return value";
}


}

package com.logicbig.example;

import org.springframework.context.annotation.AnnotationConfigApplicationContext;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.Configuration;
import org.springframework.scheduling.annotation.EnableScheduling;
import org.springframework.scheduling.annotation.Scheduled;

import java.time.LocalTime;

@EnableScheduling
@ComponentScan
@Configuration
public class ScheduledMethodReturnExample {

public static void main(String[] args) throws Exception {
AnnotationConfigApplicationContext context =
new AnnotationConfigApplicationContext(
ScheduledMethodReturnExample.class);

}
}

Output

task thread: pool-1-thread-1, time: 16:58:54.635834500
task thread: pool-1-thread-1, time: 16:58:55.630153400
task thread: pool-1-thread-1, time: 16:58:56.631426100
task thread: pool-1-thread-1, time: 16:58:57.631041600
task thread: pool-1-thread-1, time: 16:58:58.638495100
task thread: pool-1-thread-1, time: 16:58:59.629680900
task thread: pool-1-thread-1, time: 16:59:00.645981300
task thread: pool-1-thread-1, time: 16:59:01.642230
task thread: pool-1-thread-1, time: 16:59:02.634376100
task thread: pool-1-thread-1, time: 16:59:03.694373300
task thread: pool-1-thread-1, time: 16:59:04.637092300
.....................
Original Post




This example shows that methods which are annotated with @Scheduled are not allowed to have args.

package com.logicbig.example;

import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;

import java.time.LocalTime;

@Component
public class MyBean {

@Scheduled(initialDelay = 100)
public void runTask(String arg) {
System.out.println("arg: "+arg);
System.out.printf("task thread: %s, time: %s%n",
Thread.currentThread().getName(),
LocalTime.now());
try {
Thread.sleep(500);
} catch (InterruptedException e) {
}
}


}

package com.logicbig.example;

import org.springframework.context.annotation.AnnotationConfigApplicationContext;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.Configuration;
import org.springframework.scheduling.annotation.EnableScheduling;
import org.springframework.scheduling.annotation.Scheduled;

import java.time.LocalTime;

@EnableScheduling
@ComponentScan
@Configuration
public class ScheduledMethodArgExample {

public static void main (String[] args) {
AnnotationConfigApplicationContext context =
new AnnotationConfigApplicationContext(
ScheduledMethodArgExample.class);




}
}

Output

Caused by: java.lang.IllegalStateException: Could not create recurring task for @Scheduled method 'runTask': Only no-arg methods may be annotated with @Scheduled
at java.lang.Iterable.forEach (Iterable.java:75)
at java.util.LinkedHashMap.forEach (LinkedHashMap.java:987)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyBeanPostProcessorsAfterInitialization (AbstractAutowireCapableBeanFactory.java:445)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean (AbstractAutowireCapableBeanFactory.java:1829)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean (AbstractAutowireCapableBeanFactory.java:607)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean (AbstractAutowireCapableBeanFactory.java:529)
at org.springframework.beans.factory.support.AbstractBeanFactory.lambda$doGetBean$0 (AbstractBeanFactory.java:339)
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton (DefaultSingletonBeanRegistry.java:373)
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean (AbstractBeanFactory.java:337)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean (AbstractBeanFactory.java:202)
at org.springframework.beans.factory.support.DefaultListableBeanFactory.instantiateSingleton (DefaultListableBeanFactory.java:1228)
at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingleton (DefaultListableBeanFactory.java:1194)
at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons (DefaultListableBeanFactory.java:1130)
at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization (AbstractApplicationContext.java:990)
at org.springframework.context.support.AbstractApplicationContext.refresh (AbstractApplicationContext.java:627)
at org.springframework.context.annotation.AnnotationConfigApplicationContext.<init> (AnnotationConfigApplicationContext.java:93)
at com.logicbig.example.ScheduledMethodArgExample.main (ScheduledMethodArgExample.java:24)
at jdk.internal.reflect.DirectMethodHandleAccessor.invoke (DirectMethodHandleAccessor.java:104)
at java.lang.reflect.Method.invoke (Method.java:565)
at org.codehaus.mojo.exec.AbstractExecJavaBase.executeMainMethod (AbstractExecJavaBase.java:402)
at org.codehaus.mojo.exec.ExecJavaMojo.executeMainMethod (ExecJavaMojo.java:142)
at org.codehaus.mojo.exec.AbstractExecJavaBase.doExecClassLoader (AbstractExecJavaBase.java:377)
at org.codehaus.mojo.exec.AbstractExecJavaBase.lambda$execute$0 (AbstractExecJavaBase.java:287)
at java.lang.Thread.run (Thread.java:1474)
Original Post




This example shows how to schedule a task using cron expression.

package com.logicbig.example;

import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;

import java.time.LocalTime;

@Component
public class MyBean {

@Scheduled(cron = "*/2 * * * * *")
public void runTask() {
System.out.printf("Running scheduled task " +
" thread: %s, time: %s%n",
Thread.currentThread().getName(),
LocalTime.now());
}
}

package com.logicbig.example;

import org.springframework.context.annotation.AnnotationConfigApplicationContext;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.Configuration;
import org.springframework.scheduling.annotation.EnableScheduling;

@ComponentScan
@EnableScheduling
@Configuration
public class ScheduledExample {

public static void main(String[] args) {
AnnotationConfigApplicationContext context =
new AnnotationConfigApplicationContext(
ScheduledExample.class);

}

}

Output

Running scheduled task  thread: pool-1-thread-1, time: 16:09:28.007171400
Running scheduled task thread: pool-1-thread-1, time: 16:09:30.001063100
Running scheduled task thread: pool-1-thread-1, time: 16:09:32.006863900
Running scheduled task thread: pool-1-thread-1, time: 16:09:34.010686
Running scheduled task thread: pool-1-thread-1, time: 16:09:36.014262
.....................
Original Post

This example shows how to use external properties to configure scheduling.

package com.logicbig.example;

import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;

import java.time.LocalTime;

@Component
public class MyBean {

@Scheduled(initialDelayString = "${initial-delay}",
fixedDelayString = "${fixed-delay}")
public void runTask() {
System.out.printf("Running scheduled task1 " +
" thread: %s, time: %s%n",
Thread.currentThread().getName(),
LocalTime.now());
}

@Scheduled(initialDelayString = "${initial-delay}",
fixedRateString = "${fixed-rate}")
public void runTask2() {
System.out.printf("Running scheduled task2 " +
" thread: %s, time: %s%n",
Thread.currentThread().getName(),
LocalTime.now());
}

@Scheduled(cron = "${cron-expression}")
public void runTask3() {
System.out.printf("Running scheduled task3 " +
" thread: %s, time: %s%n",
Thread.currentThread().getName(),
LocalTime.now());
}
}

package com.logicbig.example;

import org.springframework.context.annotation.AnnotationConfigApplicationContext;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.PropertySource;
import org.springframework.scheduling.annotation.EnableScheduling;

@ComponentScan
@EnableScheduling
@Configuration
@PropertySource("classpath:scheduling.properties")
public class ScheduledExample {

public static void main(String[] args) {
AnnotationConfigApplicationContext context =
new AnnotationConfigApplicationContext(
ScheduledExample.class);

}

}

Output

Running scheduled task2  thread: pool-1-thread-1, time: 16:09:01.292489300
Running scheduled task1 thread: pool-1-thread-1, time: 16:09:01.292489300
Running scheduled task2 thread: pool-1-thread-1, time: 16:09:03.286634600
Running scheduled task3 thread: pool-1-thread-1, time: 16:09:04.002911300
Running scheduled task1 thread: pool-1-thread-1, time: 16:09:04.301844700
Running scheduled task2 thread: pool-1-thread-1, time: 16:09:05.297963200
Running scheduled task2 thread: pool-1-thread-1, time: 16:09:07.301290700
Running scheduled task1 thread: pool-1-thread-1, time: 16:09:07.317009300
Running scheduled task3 thread: pool-1-thread-1, time: 16:09:08.016077700
Running scheduled task2 thread: pool-1-thread-1, time: 16:09:09.293244200
Running scheduled task1 thread: pool-1-thread-1, time: 16:09:10.333258500
Running scheduled task2 thread: pool-1-thread-1, time: 16:09:11.297501200
Running scheduled task3 thread: pool-1-thread-1, time: 16:09:12.001694800
Running scheduled task2 thread: pool-1-thread-1, time: 16:09:13.295883800
Running scheduled task1 thread: pool-1-thread-1, time: 16:09:13.342918600
Running scheduled task2 thread: pool-1-thread-1, time: 16:09:15.290727300
Running scheduled task3 thread: pool-1-thread-1, time: 16:09:16.009899100
Running scheduled task1 thread: pool-1-thread-1, time: 16:09:16.355963
Running scheduled task2 thread: pool-1-thread-1, time: 16:09:17.286473100
Running scheduled task2 thread: pool-1-thread-1, time: 16:09:19.296747700
Running scheduled task1 thread: pool-1-thread-1, time: 16:09:19.359342200
Running scheduled task3 thread: pool-1-thread-1, time: 16:09:20.013199900
......................

src/main/resources/scheduling.properties:

fixed-rate=2000
fixed-delay=3000
initial-delay=1000
cron-expression=*/4 * * * * *
Original Post




This example shows how to use SpEL with @Scheduled annotation.

package com.logicbig.example;

import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;

import java.time.LocalTime;

@Component
public class MyBean {

@Scheduled(
fixedDelayString = "#{T(com.logicbig.example.ScheduledExample).getTaskRate()}")
public void runTask() {
System.out.printf("Running scheduled task " +
" thread: %s, time: %s%n",
Thread.currentThread().getName(),
LocalTime.now());
}
}

package com.logicbig.example;

import org.springframework.context.annotation.AnnotationConfigApplicationContext;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.Configuration;
import org.springframework.scheduling.annotation.EnableScheduling;

import java.util.TimeZone;

@ComponentScan
@EnableScheduling
@Configuration
public class ScheduledExample {

public static void main(String[] args) {
AnnotationConfigApplicationContext context =
new AnnotationConfigApplicationContext(
ScheduledExample.class);

}

public static String getTaskRate(){
TimeZone tz = TimeZone.getDefault();
if(tz.getID().equals("America/New_York")){
return "1000";
}else{
return "3000";
}

}

}

Output

Running scheduled task  thread: pool-1-thread-1, time: 16:08:41.937174200
Running scheduled task thread: pool-1-thread-1, time: 16:08:44.944081800
Running scheduled task thread: pool-1-thread-1, time: 16:08:47.950042600
Running scheduled task thread: pool-1-thread-1, time: 16:08:50.956851800
......................
Original Post




The following example shows how to override ScheduledAnnotationBeanPostProcessor to modify the default behavior

ScheduledAnnotationBeanPostProcessor is responsible for scanning @Scheduled methods and registering them with a TaskScheduler.

package com.logicbig.example;

import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.scheduling.annotation.ScheduledAnnotationBeanPostProcessor;

import java.lang.reflect.Method;


public class CustomScheduledBeanPostProcessor extends ScheduledAnnotationBeanPostProcessor {

@Override
protected Runnable createRunnable(Object target, Method method, String qualifier) {
//do some customizing if required
Runnable runnable = super.createRunnable(target, method, qualifier);
return () -> {
System.out.printf("Running method %s.%s%n",
target.getClass().getSimpleName(), method.getName());
runnable.run();
System.out.printf("Finished running method %s.%s%n",
target.getClass().getSimpleName(), method.getName());
System.out.println("-------");
};
}

@Override
protected void processScheduled(Scheduled scheduled, Method method, Object bean) {
System.out.printf("Processing @Scheduled method: %s.%s, scheduled Type: %s%n",
method.getDeclaringClass().getSimpleName(), method.getName(), scheduled);
super.processScheduled(scheduled, method, bean);
}
}

package com.logicbig.example;

import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;

import java.time.LocalTime;

@Component
public class MyBean {

@Scheduled(fixedDelay = 1000)
public void runTask() {
System.out.printf("task thread: %s, time: %s%n",
Thread.currentThread().getName(),
LocalTime.now());
}

@Scheduled(fixedRate = 2000)
public void runTask2() {
System.out.printf("task 2 thread: %s, time: %s%n",
Thread.currentThread().getName(),
LocalTime.now());
}
}

package com.logicbig.example;

import org.springframework.context.annotation.*;
import org.springframework.scheduling.annotation.EnableScheduling;

@EnableScheduling
@ComponentScan
@Configuration
public class ScheduledCustomizedProcessorExample {

@Bean
@Primary
public static CustomScheduledBeanPostProcessor customScheduledBeanPostProcessor() {
return new CustomScheduledBeanPostProcessor();
}

public static void main(String[] args) {
AnnotationConfigApplicationContext context =
new AnnotationConfigApplicationContext(
ScheduledCustomizedProcessorExample.class);

}
}

Output

Processing @Scheduled method: MyBean.runTask2, scheduled Type: @org.springframework.scheduling.annotation.Scheduled(scheduler="", cron="", fixedRateString="", zone="", fixedDelay=-1L, fixedRate=2000L, initialDelayString="", initialDelay=-1L, timeUnit=MILLISECONDS, fixedDelayString="")
Processing @Scheduled method: MyBean.runTask, scheduled Type: @org.springframework.scheduling.annotation.Scheduled(scheduler="", cron="", fixedRateString="", zone="", fixedDelay=1000L, fixedRate=-1L, initialDelayString="", initialDelay=-1L, timeUnit=MILLISECONDS, fixedDelayString="")
Running method MyBean.runTask2
task 2 thread: pool-2-thread-1, time: 13:58:05.597719300
Finished running method MyBean.runTask2
-------
Running method MyBean.runTask
task thread: pool-2-thread-1, time: 13:58:05.599712400
Finished running method MyBean.runTask
-------
task 2 thread: pool-1-thread-1, time: 13:58:05.608682600
task thread: pool-1-thread-1, time: 13:58:05.609678900
Running method MyBean.runTask
task thread: pool-2-thread-1, time: 13:58:06.602690300
Finished running method MyBean.runTask
-------
task thread: pool-1-thread-1, time: 13:58:06.610445
task 2 thread: pool-1-thread-1, time: 13:58:07.531037300
Running method MyBean.runTask2
task 2 thread: pool-2-thread-1, time: 13:58:07.533085600
Finished running method MyBean.runTask2
-------
Running method MyBean.runTask
task thread: pool-2-thread-1, time: 13:58:07.603913900
Finished running method MyBean.runTask
-------
task thread: pool-1-thread-1, time: 13:58:07.611711700
Running method MyBean.runTask
task thread: pool-1-thread-1, time: 13:58:08.619743700
task thread: pool-2-thread-1, time: 13:58:08.619743700
Finished running method MyBean.runTask
-------
Running method MyBean.runTask2
task 2 thread: pool-1-thread-1, time: 13:58:09.539502
task 2 thread: pool-2-thread-1, time: 13:58:09.539502
Finished running method MyBean.runTask2
-------
Running method MyBean.runTask
task thread: pool-1-thread-1, time: 13:58:09.633156400
task thread: pool-2-thread-1, time: 13:58:09.633156400
Finished running method MyBean.runTask
-------
.....................
Original Post




See Also