比方说,我做一些在Java中,如:处理超时的FutureTask
RemoteResponse response = null;
try {
FutureTask task new FutureTask(....);
executor.execute(task);
response = task.get(1000, TimeUnits.MILLISECONDS);
}
catch(TimeoutException te) {
.. should I do something special here? ... .. what happens to the return value of the task if task.get() throws an exception? ... .. is it ever garbage collected? ..
}
我的问题是没有东西不放的情况下RemoteResponse其中TimeoutException异常被抛出?它会收集垃圾吗?我是否必须在任务上调用cancel()方法才能发生?
这看起来像一个很好的方法。 – Dave 2009-09-17 03:33:28