gpt4 book ai didi

java - 获取指定队列中的任务数量?

转载 作者:太空宇宙 更新时间:2023-11-04 12:20:17 25 4
gpt4 key购买 nike

我有一个命名任务队列。有没有办法从 java API 获取当前包含的任务数?

我知道我可以检查控制台页面,但我想通过代码获取计数,以便我可以向用户报告其中有多少任务,以便他们知道在任务得到服务之前他们需要等待大约多长时间。

谢谢

最佳答案

有关队列的各种统计信息可在 Class QueueStatistics 中找到。

在某些情况下很容易错过重要的注释(可能不是您的情况,因为您只是想提供预计到达时间,而不必 100% 精确)(强调我的):

QueueStatistics allow observation of the rate that tasks on a given queue are being executed. Note that statistics provided are only approximate, and some statistics may be delayed or transiently unavailable.

您正在寻找的方法似乎是 getNumTasks :

getNumTasks

public int getNumTasks()

Returns:
The approximate number of non-completed tasks in the queue.

关于java - 获取指定队列中的任务数量?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38919548/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com