Review of solution for Cancelled Tasks
james.graham at oracle.com
Thu Jan 5 15:52:58 PST 2012
On 1/5/2012 1:53 PM, Tom Eugelink wrote:
> I must admit that I've lost the discussion somewhere.
> But seeing the code above, with the if(isCancelled()) check to break the
> loop, I do not see any need to throw an exception. The Task, after
> returing from call(), can check itself for isCancelled() and call the
> cancelled() method in the EDT (or whatever) for update. So, why an
If they are updating the progress, then they are likely unaware that
their actions are inappropriate (though it could have been a race
condition in that they might have called isCancelled() and then they got
cancelled after it returned "false" and then they call update() only to
be in the cancel condition).
It's roughly analogous to trying to read from a stream that has been
closed. It's no longer appropriate to be reading from it and so you get
an exceptional return.
There is still the issue being discussed that in some cases it may be
appropriate to update progress if the action has been canceled, though...
More information about the openjfx-dev