Are the threads generated by 2 separate executor services in different threads guaranteed to be different?

StackOverflow https://stackoverflow.com/questions/22622894

質問

Lets say I have 2 different threads running concurrently. Each thread spins up a cached thread pool executor service that spins a bunch more threads. Will each pool have their own distinct set of threads? Or is there a possibility for threads to be shared between them?

役に立ちましたか?

解決

Will each pool have their own distinct set of threads? Or is there a possibility for threads to be shared between them?

Each pool has control over its own threads -- when to create new ones, when to destroy them etc. No two ThreadPools will ever "see" one another's threads.

In other words: there is no "giant pool" at the JVM level from which ExecutorServices, or ScheduledExecutorServices or even ForkJoinPools would pick from. Were it the case, the maintenance cost would be prohibitive...

ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top