您只需要将目标对象包装在中
Runnable,然后提交:
private Target target; // this is a Spring bean of some kind@Autowired private TaskScheduler taskScheduler;public void scheduleSomething() { Runnable task = new Runnable() { public void run() { target.doTheWork(); } }; taskScheduler.scheduleWithFixedDelay(task, delay);}
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)