Results 1 to 7 of 7

Thread: Communication/data sharing between threads

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Mar 2010
    Posts
    77
    Thanks
    17
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Communication/data sharing between threads

    Yeah, I've read that but I was lead to believe that this was only necessary when the variables in question had multiple threads that wanted to write to them. Only one of my threads write to a variable and the other threads are strictly readers.
    Isn't that true?

    /Tottish

    EDIT: Tested with mutex. No difference.
    Last edited by Tottish; 15th April 2010 at 08:40.

  2. #2
    Join Date
    Mar 2008
    Location
    Kraków, Poland
    Posts
    1,540
    Thanked 284 Times in 279 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Communication/data sharing between threads

    Show us some code : declaration of this variables and code accessing them. The glass ball is not working today

  3. #3
    Join Date
    Sep 2009
    Location
    UK
    Posts
    2,447
    Thanks
    6
    Thanked 348 Times in 333 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Communication/data sharing between threads

    If you have a thread that writes and a thread that reads, you need locking unless the variables are simple types such as 'char'.

    Have a look at QReadLocker & QWriteLocker. The former locks for read access, the later locks for write access.

  4. #4
    Join Date
    Nov 2012
    Posts
    48
    Thanks
    4
    Qt products
    Qt3 Qt4 Qt/Embedded
    Platforms
    Unix/X11 Windows

    Default Re: Communication/data sharing between threads

    dear Lesiok,
    I have some how such a problem with data sharing with different threads.
    but the difference is that when I wanna read a static array in different array they know it by different address :-??

Similar Threads

  1. Communication between Threads
    By Wan-Hi in forum Newbie
    Replies: 11
    Last Post: 24th January 2013, 12:52
  2. Sharing between two Threads
    By donglebob in forum General Programming
    Replies: 2
    Last Post: 30th October 2008, 08:58
  3. Sharing data between threads
    By bbui210 in forum Qt Programming
    Replies: 15
    Last Post: 19th October 2008, 17:56
  4. Sharing data across threads
    By jphn_crichton in forum Qt Programming
    Replies: 11
    Last Post: 5th May 2008, 18:29
  5. Threads communication
    By probine in forum Qt Programming
    Replies: 4
    Last Post: 31st March 2006, 14: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.