You can only stop threads that return from their run method. The Thread Manager stops each thread the next time it returns from its run method.
You can stop threads in two ways:
By decreasing the thread count Call the ThreadManager::setThreadCount method to reduce the number of threads executing in the thread group. This technique is useful when you want to throttle the execution of the task. For example, during a Web site’s peak usage hours, you can reduce the thread count for background processing to give user threads more CPU time. During off hours, you can reset the thread count and start new threads to raise the thread count again.
By stopping all threads in the group Call the ThreadManager::stop method to stop all threads in the group. This method is equivalent to calling ThreadManager::setThreadCount to reduce the thread count to zero.
If you stop all threads by calling ThreadManager::stop or setting the thread count to 0, you must reset the thread count to a positive value or -1 (meaning infinity) before starting more threads.