Multithreading, when to yield versus sleep

Posted by aaa on Stack Overflow See other posts from Stack Overflow or by aaa
Published on 2010-04-19T15:15:05Z Indexed on 2010/04/19 15:23 UTC
Read the original article Hit count: 214

Filed under:
|
|
|

hello.

To clarify terminology, yield is when thread gives up its time slice. My platform of interest is POSIX threads, but I think question is general.

Suppose I have consumer/producer pattern. If I want to throttle either consumer or producer, which is better to use, sleep or yield? I am mostly interested in efficiency of using either function.

Thanks

© Stack Overflow or respective owner

Related posts about multithreading

Related posts about yield