Results 1 to 2 of 2

Thread: Multithreaded spend CPU 100%

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Nov 2008
    Posts
    10
    Qt products
    Qt4
    Platforms
    Windows

    Default Multithreaded spend CPU 100%

    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:

    Qt Code:
    1. void Thread::run()
    2. {
    3. while (!stopped)
    4. printf("%s",&messageStr);
    5. std::cerr << qPrintable(messageStr);
    6. stopped = false;
    7. std::cerr << std::endl;
    8. }
    To copy to clipboard, switch view to plain text mode 
    Last edited by jpn; 18th December 2008 at 15:45. Reason: missing [code] tags

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Qt is a trademark of The Qt Company.