Thursday, September 16, 2004

Basic Instincts: Thread Synchronization -- MSDN Magazine, September 2004

Basic Instincts: Thread Synchronization -- MSDN Magazine, September 2004: "The Dangers of Concurrency

Some programming problems do not surface until you begin to execute the code associated with a class or object on multiple threads at once. For example, when multiple threads are executing methods concurrently on a single object, it opens up the possibility of one thread seeing data that's been left in an inconsistent or corrupt state by another thread. This is possible because of the way in which threads are scheduled by the underlying operating system.
The way the operating system's thread scheduler preempts one thread and begins to execute another thread is nondeterministic, meaning that a thread may be preempted while in the middle of a set of related update operations. This makes it possible for a second thread to gain control of the processor and to see the first thread's partially completed work."

No comments: