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, ...

Get Microsoft® Visual C#® .NET 2003 Unleashed now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.