Results 1 to 4 of 4

Thread: Threads problem

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Feb 2006
    Location
    Oslo, Norway
    Posts
    6,264
    Thanks
    36
    Thanked 1,519 Times in 1,389 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows Symbian S60 Maemo/MeeGo

    Default Re: Threads problem

    Quote Originally Posted by boss_bhat
    Can some body explain how to do it?
    Start of by reading Thread Support in Qt. Then, see Qt's threading examples at /examples/threads.

    A few hints:
    • if you really want it to enter to an infinite loop inside run(), you'll need wait conditions
    • another (and maybe easier) option would be to enter to an event loop instead
    J-P Nurmi

  2. #2
    Join Date
    Jun 2006
    Posts
    34
    Thanks
    2
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Threads problem

    I did something like this, it works fine but is this the right way of doing ??

    Qt Code:
    1. void ThinThread ::run ()
    2. {
    3.  
    4. label:
    5.  
    6. while(suspFlag)
    7. {
    8. sleep(1);
    9. cout <<" in the thread "<< endl;
    10. }
    11. if (!suspFlag)
    12. {
    13. while (!suspFlag)
    14. {
    15. sleep(1);
    16. }
    17. }
    18.  
    19. goto label;
    20.  
    21. cout <<"done with the thread\n";
    22. }
    23.  
    24. void ThinThread::suspend()
    25. {
    26. suspFlag=false;
    27. }
    28. void ThinThread::resume()
    29. {
    30. suspFlag=true;
    31.  
    32. }
    To copy to clipboard, switch view to plain text mode 

    please suggest me on this
    Thanks in advance,
    Boss
    Last edited by jacek; 2nd August 2006 at 15:30. Reason: added code tags

  3. #3
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    5,372
    Thanks
    28
    Thanked 976 Times in 912 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Threads problem

    Quote Originally Posted by boss_bhat
    I did something like this, it works fine but is this the right way of doing ??
    Better use QWaitCondition.

    And please use the [ code ] tags.

Similar Threads

  1. Grid Layout Problem
    By Seema Rao in forum Qt Programming
    Replies: 2
    Last Post: 4th May 2006, 12:45
  2. Problem with bitBlt
    By yellowmat in forum Newbie
    Replies: 1
    Last Post: 5th April 2006, 14:08
  3. fftw problem
    By lordy in forum General Programming
    Replies: 1
    Last Post: 16th March 2006, 21:36
  4. Replies: 16
    Last Post: 7th March 2006, 15:57
  5. Problems with threads and windows
    By SkripT in forum Qt Programming
    Replies: 15
    Last Post: 16th January 2006, 17:46

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.