How to respond to canceled future downloads in a thread pool?

I use ThreadPoolExecutor to perform some actions, at some point I canceled some future tasks and saved them in the list to perform some other tasks, and after that I want to respond to saved canceled future tasks.

But the problem is that when I send the task to the pool, it will not be executed, it looks like the canceled or executed flag is saved and recognized by the thread executor, and thus this thread will not be called.

What should I do?

+3
source share
3 answers

FutureTask . , run() , CAS, , Callable call(). Callable FutureTask .

, ... ? ? , ThreadPoolexecutor PriorityBlockingQueue Comparator, . , PriorityBlockingQueue Comparator.

+3

Runnable . Runnable , Thread, Runnable .

+1
+1
source

Source: https://habr.com/ru/post/1772352/


All Articles