我在编写代码时遇到此警告(使用-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> {
如何修复警告?
答案 0 :(得分:3)
根据FutureTask
documentation,这个类也是一个泛型类。这意味着你需要
FutureTask<String> task = new FutureTask<String>(new Return(address, lock));