开发者

Can I know the number of tasks awaiting execution in ScheduledThreadPoolExecutor?

开发者 https://www.devze.com 2023-02-26 03:16 出处:网络
I am using ScheduledThreadPoolExecutor: threadPoolEx = new ScheduledThreadPoolEx开发者_如何转开发ecutor(limit);

I am using ScheduledThreadPoolExecutor:

threadPoolEx = new ScheduledThreadPoolEx开发者_如何转开发ecutor(limit);

I want to know the number of tasks awaiting execution, or just to know if there are any tasks waiting (not necessarily the number).

How can I do that? Thanks.


ScheduledThreadPoolExecutor has a getQueue() method that you can use. You can query that for various bits of info on the waiting tasks (e.g. getQueue().getSize()).

0

精彩评论

暂无评论...
验证码 换一张
取 消