yield does not suspend the current thread - it moves it in the opposite direction of the execution queue. It is still in the run queue, it just makes sure that other runnable threads (potentially not all runnable threads, if there are several run contexts that make this a pretty weak guarantee) have a chance to run before it continues. For the most part, you should ignore yield . The exception is when you understand exactly what he is doing and why it matters.
To pause and resume a thread, MVar is the way to go. When a thread expects an empty MVar , it is removed from the execution queue. When a value is placed in an MVar , the thread waits on it (I believe in the GHC that there is always a thread that expected the MVar the longest, but it is not guaranteed) is returned to the execution queue.
source share