The Java Concurrency API gives you Executor
and ExecutorService
interfaces to build from, and ships with several concrete implementations (ThreadPoolExecutor
and ScheduledThreadPoolExecutor
).
I'm completely new to Java Concurrency, and am having difficulty finding answers to several very-similarly-related questions. Rather than cluttering SO with all these tiny questions I decided to bundle them together, because there's probably a way to answer them all in one fell swoop (probably because I'm not seeing the whole picture here):
- Is it common practice to implement your own
Executor
/ExecutorService
? In what cases would you do this instead of using the two concretions I mention above? In what cases are the two concretions preferable over something "homegrown"? - I don't understand how all of the concurrent collections relate to
Executor
s. For instance, doesThreadPoolExecutor
use, say,ConcurrentLinkedQueue
under the hood to queue up submitted tasks? Or are you (the API developer) supposed to select and use, say,ConcurrentLinkedQueue
inside your parallelizedrun()
method? Basicaly, are the concurrent collections there to be used internally by theExecutor
s, or do you use them to help write non-blocking algorithms? - Can you configure which concurrent collections an
Executor
uses under the hood (to store submitted tasks), and is this common practice?
Thanks in advance!