Hacker News new | ask | show | jobs
by vips7L 2233 days ago
How can't a CF be cancelled?

Since JDK8: https://docs.oracle.com/javase/8/docs/api/java/util/concurre...

1 comments

> > A CF can't decide to sleep for a while, nor can it be cancelled.

> How can't a CF be cancelled?

So glad you brought up the docs. CF implements cancel(boolean mayInterruptIfRunning)... which does nothing ;)

More precisely, it will not cancel a running CF. If the CF hasn't started yet, by all means cancel it. But if it's running, that cancel method does nothing.