我需要创建BlockingQueue<Runnable>
实例以将其放在ThreadPoolExecutor
构造函数中。这是我的简化结构:
interface A extends Runnable { }
(实际上,我的A
&#39;类扩展了RunnableFuture<T>
)
class AComparator implements Comparator<A> {
@Override
public int compare(A o1, A o2) { return 0; }
}
实例化:
BlockingQueue<Runnable> bq = new PriorityBlockingQueue<A>(0, new AComparator());
我收到错误:
类型不匹配:无法转换为PriorityBlockingQueue&lt; A &gt;
到BlockingQueue&lt; Runnable &gt;
如何解决?