hbase client包下的AsyncProcess类中的waitForMaximumCurrentTasks方法的疑问

thefansofjay 2019-08-06 09:55:17
hbase版本是1.0.0,该方法如下
/** Wait until the async does not have more than max tasks in progress. */
private void waitForMaximumCurrentTasks(int max) throws InterruptedIOException {
long lastLog = EnvironmentEdgeManager.currentTime();
long currentInProgress, oldInProgress = Long.MAX_VALUE;
while ((currentInProgress = this.tasksInProgress.get()) > max) {
if (oldInProgress != currentInProgress) { // Wait for in progress to change.
long now = EnvironmentEdgeManager.currentTime();
if (now > lastLog + 10000) {
lastLog = now;
LOG.info("#" + id + ", waiting for some tasks to finish. Expected max="
+ max + ", tasksInProgress=" + currentInProgress);
}
}
oldInProgress = currentInProgress;
try {
synchronized (this.tasksInProgress) {
if (tasksInProgress.get() != oldInProgress) break;
this.tasksInProgress.wait(100);
}
} catch (InterruptedException e) {
throw new InterruptedIOException("#" + id + ", interrupted." +
" currentNumberOfTask=" + currentInProgress);
}
}
}

我的问题是
synchronized (this.tasksInProgress) {
if (tasksInProgress.get() != oldInProgress) break;
this.tasksInProgress.wait(100);
}
这段代码是什么作用,假如max = 0,那么当运行到这的时候,假如tasksInProgress.get() != oldInProgress,break了,那么
此时taskInProgress > 0?百思不得其解,求大神指教。


...全文
517 回复 打赏 收藏 转发到动态 举报
写回复
用AI写文章
回复
切换为时间正序
请发表友善的回复…
发表回复

1,092

社区成员

发帖
与我相关
我的任务
社区描述
云计算服务器、网络、虚拟化相关讨论
社区管理员
  • 服务器
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧