If I call task.wait() inside a thread that is managed by the thread pool, is that thread handed back to the thread pool so that it can be reused elsewhere while waiting or is it kept idle (therefore not reused) until the task completes ?

I would suspect the second one as it would be the behaviour for any thread that is not managed by the thread pool.

有帮助吗?

解决方案

Simple answer: No. The thread has no concept of a thread pool, so Wait can not do special things. Also reusing a thread like this may have serious side effects (on thread local variables which may have changed).

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top