我想实例化一个新的Java ThreadPoolExecutor
与这段代码:泛型结构:Java不承认,我自己的类实现一个接口
public class ImageList {
private LinkedBlockingQueue<Image> list;
private final ThreadPoolExecutor executor;
public ImageList() {
executor = new ThreadPoolExecutor(2, 4, 100, TimeUnit.SECONDS, list);
}
}
凡Image
具有以下标题:
public class Image implements Runnable, Serializable
但是,Java抱怨没有找到类型BlockingQueue<Runnable>
的构造函数。我究竟做错了什么?
泛型中的继承与类中的继承稍有不同。您需要使用通配符http://docs.oracle.com/javase/tutorial/java/generics/inheritance.html – kosa 2012-07-13 14:52:31
泛型和多态:http://stackoverflow.com/questions/2745265/is-listdog-a-subclass -of-listanimal-why-arent-javas-generics-implicit – assylias 2012-07-13 14:56:41