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