I would like to understand how 'wait' on a thread is actually working ? Is there an endless loop behind the scene (does not sound resonable) ?
For example in MSDN/MFC manual page for 'WaitForSingleObject' function it says
The WaitForSingleObject function checks the current state of the specified object. If the object's state is nonsignaled, the calling thread enters the wait state until the object is signaled or the time-out interval elapses. (http://msdn.microsoft.com/en-us/library/windows/desktop/ms687032(v=vs.85).aspx)
What is this "wait state"? How does the thread 'wake up' i.e. how rising an event or signale an object cause the thread to run again? Who checks the synchronization object and how often?
Thank you