后台线程启动实例
@Component
public class DataProcessController implements Runnable{
@Value("${params}")
private String params;
@Autowired
private MongoTemplate mongoTemplate;
@PostConstruct
public void init(){
new Thread(this).start();
}
@Override
public void run() {
synchronized(this){
while (true){
try {
if(linkedBlockingQueue.isEmpty()){
try {
Thread.sleep(100);
} catch (InterruptedException e) {
e.printStackTrace();
}
}else{
executeTask();
}
} catch (Exception e) {
e.printStackTrace();
}
}
}
}
public void executeTask(){
}
}