知乎专栏 |
public static Random random = new Random(); @Async("jobExecutor") public void doAsyncTask() throws InterruptedException { Thread.currentThread().setName("测试线程-" + random.nextInt(1000)); System.out.println("开始做任务一"); long start = System.currentTimeMillis(); Thread.sleep(random.nextInt(100000)); long end = System.currentTimeMillis(); System.out.println("完成任务一,耗时:" + (end - start) + "毫秒"); }