把要注入的Service,通过构造传过去
1.controller层
@Autowired
private ThreadPoolTaskExecutor taskExecutor;
@Autowired
private TaginfoService taginfoService;
@RequestMapping("/test")
@ResponseBody
public Object index(String mac){
Thread thread = new DealData2(taginfoService);
taskExecutor.execute(thread);
return null;
}
2.线程类
public class DealData2 extends Thread {
private TaginfoService taginfoService;
public DealData2(TaginfoService taginfoService) {
this.taginfoService = taginfoService;
}