Future
that was sent to an ExecutorService
. I told them to look at a previous posts I had done on the subject. However, they insisted that this was different. So I took a look at the code. Alas, it was slightly different, but like most folks including me, they were too close to the problem to see the answer. I looked at it, and at first glance I thought something was askew, but it was not.
The code for this project can be downloaded here: runnable-example
As you can see from the results of the run, the future is canceled, but still keeps running. Then it gets interrupted, and breaks. So the question is why is it still running after being canceled.
Here is the
Runnable
and the main class to execute it:
MyRunnable.java
Main.java
So the do you have an answer? The answer is at the bottom of the blog. Don't peek... think!
Reference
- How do you cancel a scheduled Thread in an ExecutorService?
- How to exercise your Daemons - Callable, Future, and ExecutorService
- ExecutorService and CountDownLatch Example
0 comments :
Post a Comment