我在编译代码时收到此警告(使用-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> {
如何解决警告?
最佳答案
根据FutureTask
documentation,此类也是通用类。这意味着您需要
FutureTask<String> task = new FutureTask<String>(new Return(address, lock));
关于java - FutureTask,不安全的操作,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/13027835/