be notified when all background threadpool threads are finished

后端 未结 7 1820
星月不相逢
星月不相逢 2020-12-16 01:37

I have a scenario when I start 3..10 threads with ThreadPool. Each thread does its job and returns to the ThreadPool. What are possible options to be notified in main thread

相关标签:
7条回答
  • 2020-12-16 02:34

    What about using Semaphore, and set a limit to it as much as your thread pool. Have a method to fetch a Semaphore, to be called when you start your thread, release it when your thread end and raise an event if you've taken up all the Semaphore.

    0 讨论(0)
提交回复
热议问题