windows线程运行一段时间一直停在sleep被阻塞, 谢谢各位大佬 JVM线程
程序员文章站
2023-12-24 13:43:39
...
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); //BusinessInfo businessInfo = sessionInfo.getBusinessInfo(); //log.info("[{}]SYNCING[{}][{}]: busiTypeName={}, busiType={}, transTimestamp = '{}',transOffsetId = {},conf.szie = {}", Thread.currentThread().getName(),transType, businessInfo.getBusinessId(), conf.getBusiTypeName(), conf.getBusiType(), busiTransVo.getTransTimestamp(), busiTransVo.getTransOffsetId(), busiBlockingQueue.size()); 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); } }
线程被阻塞, 也未发现死锁