Can I know the number of tasks awaiting execution in ScheduledThreadPoolExecutor?
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()
).
精彩评论