I run C++ GUI Qt 4 programing(Editor 2)14th Multithreaded example Threads, found when a thread started, the CPU be ueed up 100% performance. It may be caused in thread::run() while loop. How to reduce the CPU spending? The Thread::run() see below:
void Thread::run()
{
while (!stopped)
printf("%s",&messageStr);
std::cerr << qPrintable(messageStr);
stopped = false;
std::cerr << std::endl;
}
void Thread::run()
{
while (!stopped)
printf("%s",&messageStr);
std::cerr << qPrintable(messageStr);
stopped = false;
std::cerr << std::endl;
}
To copy to clipboard, switch view to plain text mode
Bookmarks