When a manual-reset event is signaled,
all threads waiting on the event
become schedulable. When an auto-reset
event is signaled, only one of the
threads waiting on the event becomes
schedulable.
I have some really noob questions here to ask, as I’m new to threading.
- What does it mean to “set” and “reset” an event?
- What is the difference between a manual-reset and auto-reset event?
- What does it mean when an event is “signaled”? Does it mean it is activated?
- What does it mean when a thread becomes “schedulable” ?
- What is “waiting on the event” ?
Basically, a “WaitHandle” (which includes both Manual Reset Events and Auto Reset Events) are types that allow a thread to wait until something happens – in this case, until the WaitHandle is “Set”.
A thread (Thread A) can “wait” on a WaitHandle, blocking until a separate thread (Thread B) “sets” (==”signals”) the WaitHandle. This will allow thread A to continue on at that point.
The main difference occurs if you have multiple threads waiting on the WaitHandle. In this case, with a Manual reset event, all of the threads will be allowed to continue on (ie: they’re now schedulable, which means the OS will set them up and run them again at some point, usually fairly quickly). With an auto reset event, one thread is allowed to continue, and the WaitHandle is “reset”, which prevents the other threads from continuing (until the WaitHandle is signaled again, when the next thread is “released”).