Very important, although not usually described in textbooks:
Runnables to be executed on an ExecutorService should not block. This is because each lock disables the workflow, and if the ExecutorService has a limited number of workflows, there is a risk of a dead end (thread puzzle), and if the ExecutorService has an unlimited number of workflows, then there is a risk that memory runs out. Blocking operations in tasks simply destroy all the benefits of ExecutorService, so use blocking operations only for regular threads.
FutureTask.get()is a lock, so it can be used for regular threads, and not from the ExecutorService task. That is, it cannot serve as a building block, but only to deliver the result of execution to the main stream.
- , , . , , , . , . , , Runnable , ExcutorServices.
( ).
, Akka, , , - .
, https://github.com/rfqu/df4j.