我可以知道在ScheduledThreadPoolExecutor中等待执行的任务数量吗?

时间:2011-04-18 08:52:01

标签: java threadpool

我正在使用ScheduledThreadPoolExecutor:

threadPoolEx = new ScheduledThreadPoolExecutor(limit);

我想知道等待执行的任务数量,或者只知道是否有任何等待任务(不一定是数字)。

我该怎么做? 感谢。

1 个答案:

答案 0 :(得分:2)

ScheduledThreadPoolExecutor有一个getQueue()方法可以使用。您可以查询等待任务的各种信息(例如getQueue().getSize())。