Let's say I do something in Java like:
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? ..
}
My question is does something hold onto RemoteResponse in the case where TimeoutException is thrown? Will it get garbage collected? Do I have to call the cancel() method on the task for that to happen?