<分区>
Possible Duplicate:
Java Executors: how can I set task priority?
我有一个使用 LinkedBlockingDequeue 构建的 ThreadPoolExecutor,我想操纵底层队列,但是在文档中阅读它让我非常紧张。
Queue maintenance
Method getQueue() allows access to the work queue for purposes of monitoring and debugging. Use of this method for any other purpose is strongly discouraged. Two supplied methods, remove(java.lang.Runnable) and purge() are available to assist in storage reclamation when large numbers of queued tasks become cancelled.
特别是我希望能够
- 检查队列以查看元素是否已存在。我认为这很好,因为不需要锁定就可以查看队列中的元素。
- 我想根据一些信号对队列重新排序。这显然很麻烦。我想知道是否有更好的方法来执行此操作,这样我就不会弄乱队列用于其他用途。
谢谢