[Qt-interest] Multithreading - yield function

Patric userqt at gmail.com
Tue Sep 1 11:56:52 CEST 2009


>The function works.

>It just doesn't do what you expect it to do. You're expecting that another
>thread gets woken up and run, while your thread is suspended for a long 
>time.

>That's not what happens. That only causes the current thread to give up its
>processor time. Other threads may wake up, if they are ready for execution.
>But the current thread will wake up too, very soon.

>If you don't insert a synchronisation primitive, like a QWaitCondition or a
>QSemaphore, there's no guarantee of how long your thread will get suspended
>for. It may get suspended but then woken up again before the other thread
>finishes execution.

>If you want to program with threads, I recommend you read some books on the
>subject first. It is *very* tricky to get it right. Programming threads 
>when,
>like you said, you don't have much experience, is a very daunting task.

------------------------------------------------------------------------------------

Also when I'm debugging and it's clear that another thread is waiting for 
execution, after yield it's just not jumping to the other thread.

>It may get suspended but then woken up again before the other thread 
>finishes execution.

you are telling me that if I have two threads that are running, I really 
don't know when the second one will start executing in the middle of the 
code ? And stop also.
This don't sound very cool.



----- Original Message ----- 
From: "Thiago Macieira" <thiago.macieira at trolltech.com>
To: <qt-interest at trolltech.com>
Sent: Monday, August 31, 2009 11:37 PM
Subject: Re: [Qt-interest] Multithreading - yield function


> _______________________________________________
> Qt-interest mailing list
> Qt-interest at trolltech.com
> http://lists.trolltech.com/mailman/listinfo/qt-interest
> 




More information about the Qt-interest-old mailing list