大部分使用 bean 服务的时候都是单例,
我采用的是构造器注入, 创建多线程任务的时候注入
public class DuiZhanRoomTread implements Runnable {
private Runtime runtime;
private DuiZhanService duiZhanService;
private CompetitionService competitionService;
public DuiZhanRoomTread(Runtime runtime, DuiZhanService duiZhanService) {
this.runtime = runtime;
this.duiZhanService = duiZhanService;
}
@Override
public void run() {
// 在此调用服务
}
}