2020
10-10
10-10
java定时任务实现的4种方式小结
1.java自带的TimerTimertimer=newTimer();timer.schedule(newTimerTask(){@Overridepublicvoidrun(){System.out.println("Time'sup!");}},3*1000,1000);2.ScheduledThreadPool-线程池ScheduledExecutorServicescheduledThreadPool=Executors.newScheduledThreadPool(2);scheduledThreadPool.scheduleAtFixedRate(newRunnable(){@Overridepublicvoidrun()...
继续阅读 >