I have a while loop executed by each thread.
After some iterations a thread exits the loop when the condition of the while is not met.
Other threads may keep running the loop.
I would like to use the threads that exited the loop to help those that are still doing the loop.
For instance suppose 999 threads exited finished their task and exited the loop. And two threads remain running the loop.
I’d like each of the remaining two threads use the 999 threads to do some work.
Is there a way of freeing the 999 threads, I.e., terminating them, and let each of the remains two threads launch new threads to help finish the work?