单线程获取数据,如果有数据就循环执行,如果获取不到数据执行10次退出
public class JikaoUtils {
public static ExecutorService singleThreadExecutor = Executors.newSingleThreadExecutor();
}
处理业务逻辑的线程
public class GetScoreSingletonThread extends Thread {
private Integer rootOrgId;
private Map authHeader ;
/**
* 是否正在处理
*/
private AtomicBoolean running ;
public GetScoreSingletonThread(Map map,Integer _rootOrgId, NetSignupService _signupService, Long yearId, AtomicBoolean _running)
{ super();
this.authHeader = map;
this.rootOrgId = _rootOrgId;
this.signupService = _signupService;
this.yearId = yearId;
this.running = _running;
}
public void run() {
if (!running.compareAndSet(false, true)) {
return;
}
int count = 0;
while (true) {
try {
if (!execute()) {
break;
}