Results 1 to 2 of 2

Thread: Best way to coordinate two threads?

  1. #1
    Join Date
    Mar 2010
    Location
    Heredia, Costa Rica
    Posts
    257
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows
    Thanks
    24
    Thanked 17 Times in 14 Posts

    Default Best way to coordinate two threads?

    Hi,

    I working in a program that inserts a massive file into a database. I want to separate the program in two threads:

    1. The first thread process and separates the massive file into several files.

    2. The second thread should wait for a portion of the file created by thread 1 and insert it into the database.

    I want to separate the processing of the massive file into two concurrent processes that could process and insert the massive file at the same time, so It takes less time.

    What would it be the best way to coordinate the two threads? Signals and Slots?

    Thanks,
    Carlos.

  2. #2
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,376
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Thanks
    4
    Thanked 5,019 Times in 4,795 Posts
    Wiki edits
    10

    Default Re: Best way to coordinate two threads?

    The simplest solution is to use QMutex with QWaitCondition or QSemaphore. You have a classic producer-consumer pattern here.
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  3. The following user says thank you to wysota for this useful post:

    qlands (1st April 2012)

Similar Threads

  1. Get address from GPS coordinate
    By seanasl in forum Qt Programming
    Replies: 3
    Last Post: 24th January 2012, 08:09
  2. coordinate transfrom on Max OS X
    By yxtx1984 in forum Qt Programming
    Replies: 0
    Last Post: 27th November 2010, 04:03
  3. Qt Threads vs Native Threads performance
    By StackOverflow in forum Qt Programming
    Replies: 1
    Last Post: 14th November 2010, 13:14
  4. coordinate system
    By Wojtek.wk in forum Newbie
    Replies: 7
    Last Post: 12th April 2010, 14:47
  5. The coordinate system
    By avis_phoenix in forum Qt Programming
    Replies: 1
    Last Post: 28th July 2008, 13:16

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.