1

我在编译代码时收到此警告(使用 -Xlint 选项):

receptor.java:286: warning: [unchecked] unchecked call to 
FutureTask(java.util.concurrent.Callable<V>) as a member 
of the raw type java.util.concurrent.FutureTask

生成警告的行:

FutureTask task = new FutureTask (new Return(address, lock));

Return 类实现了 Callable:

public class Return implements Callable <String> {

如何修复警告?

4

1 回答 1

3

根据FutureTask文档,这个类也是一个泛型类。这意味着你需要

FutureTask<String> task = new FutureTask<String>(new Return(address, lock));
于 2012-10-23T09:56:54.960 回答