[concurrency-interest] the remove-on-cancel policy on ScheduledThreadPoolExecutor

Sangjin Lee sjlee at apache.org
Tue Aug 31 01:12:50 EDT 2010


Maybe this has been discussed in the past...

I've always been curious why ScheduledFuture.cancel() would not also remove
tasks from the queue (so would keep them live until the delay elapses) as an
optional behavior. I know one can override the decorateTask() method to
achieve the same effect, but it's slightly less than optimal as you need to
create an additional delegate object to achieve the same goal. Then I
checked the upcoming JDK 7 changes, and there seems to be such a setting
called the remove-on-cancel policy!

I looked some old versions of ScheduledThreadPoolExecutor, and it seems this
behavior was in but was removed at some point? Could someone shed light on
why it was decided not to include it in the existing versions of JDK? And
why the change in JDK 7? I would love to have this behavior, but I'm just
curious about the reason behind these decisions. Thanks!

Regards,
Sangjin
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://cs.oswego.edu/pipermail/concurrency-interest/attachments/20100830/e48c9d0f/attachment.html>


More information about the Concurrency-interest mailing list