Synchronization
With the introduction of Win32 came preemptive multitasking. Preemptive multitasking means that a thread may be interrupted at any time to allow another thread to process. This happens without regard to the state of the thread. This also means that if one thread is trying to write to a variable and another thread is trying to read that same variable, the outcome can be indeterminate. Imagine raising an apple to eat it and at the same time you begin to take a bite, someone else shoves his head in there and takes a bite first. Besides potentially getting an unexpected taste of human hair, the result is that you don't get what you wanted or expected. If you don't employ some sort of synchronization scheme in your multithreaded applications, ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access