Skip to content

Commit

Permalink
feat: 优化等待的写法
Browse files Browse the repository at this point in the history
  • Loading branch information
citmina committed Mar 25, 2024
1 parent 5d12b9f commit 1d76c0a
Showing 1 changed file with 12 additions and 13 deletions.
25 changes: 12 additions & 13 deletions src/main/java/com/gearwenxin/schedule/TaskConsumerLoop.java
Original file line number Diff line number Diff line change
Expand Up @@ -111,21 +111,20 @@ public void eventLoopProcess(String modelName) {
submitTask(task);
taskManager.upModelCurrentQPS(modelName);
} else {
try {
Thread.sleep(1000);
} catch (InterruptedException e) {
log.error("[{}] thread sleep error", TAG);
Thread.currentThread().interrupt();
}
sleep(1000);
}
} else {
try {
log.debug("[{}] [{}] current qps: {}, wait...", TAG, modelName, currentQPS);
Thread.sleep(1000);
} catch (InterruptedException e) {
log.error("[{}] thread sleep error", TAG);
Thread.currentThread().interrupt();
}
// TODO: 待优化
sleep(1000);
}
}

private void sleep(long millis) {
try {
Thread.sleep(millis);
} catch (InterruptedException e) {
log.error("[{}] thread sleep error", TAG);
Thread.currentThread().interrupt();
}
}

Expand Down

0 comments on commit 1d76c0a

Please sign in to comment.