1. 在windows部署个项目, 线程每隔一段时间同步一次数据, 但是运行一段时间就一直停在sleep, 查看状态被阻塞 , 其他的线程也被BLOCKED
while (true) { try { //全量同步: 取完queue配置, 同步结束 //增量同步: 循环配置里的内容 conf = busiBlockingQueue.poll(5000L, TimeUnit.MILLISECONDS); //log.info("conf = {},busiBlockingQueue.size = {}", (conf == null ? "null" : conf.getBusiType()), busiBlockingQueue.size()); if (conf == null && transType == TransConstants.TransType.FULL) { break; } //同步数据并处理数据 try { //是否成功获得同步标识 BusiTransVo busiTransVo = buildTransVo(transType, conf, sessionInfo); transDataService.dataHandle(transType, conf, busiTransVo, sessionInfo); } catch (Exception e) { log.error(e.getMessage(), e); } if (transType == TransConstants.TransType.INCR) { busiBlockingQueue.put(conf); Thread.sleep(ConvertUtil.convertObjectToLong(conf.getBusiTransFrequency(),2000L)); } } catch (Exception e) { log.error(conf == null ? "Conf is null" : conf.toString()); log.error(e.getMessage(), e); } }
线程被阻塞, 也未发现死锁
Thread 46: (state = BLOCKED) - java.lang.Thread.sleep(long) @bci=0 (Interpreted frame) - com.hydee.h3.pos.local.impl.sync.upload.TransUpServiceImpl.lambda$doTransUp$0(com.hydee.h3.pos.api.entity.sync.SessionInfo) @bci=72, line=77 (Compiled frame) - com.hydee.h3.pos.local.impl.sync.upload.TransUpServiceImpl$$Lambda$451.run() @bci=8 (Interpreted frame) - java.lang.Thread.run() @bci=11, line=748 (Interpreted frame)