CPU usage 100% due to loops in multiple threads
I have an linux application (written in C++), which spawns 60 threads, and all these 60 threads executes an nested loop which iterates around 100 times. Number of iterations is same for all the threads. When I spawn only one thread time taken by application is just 10-20 seconds. When I run with 60 threads time taken increases to more than 1 minute. Also CPU usage goes to 100% and stays there for more than 1 minute till the application exits. When CPU usage is 100% I cannot run any other commands. Since I need to run this application for every 5 minutes I keep hitting this problem. Please can anyone suggest a solution for this. How can I avoid loop? Is there any way to avoid 100% CPU usage inspite of this loop. Please HELP.
Thanks in advance.