比方說,我做一些在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