Locator+ Code:   
Search:   
FTPOnline
Magazines Resources Hot Topics Partner Sites About FTP RSS 2.0 Feed



email article
printer friendly
get the code

Sync Threads Automatically
Simplify the management of .NET component concurrency by using automatic thread synchronization to prevent deadlocks.
by Juval Löwy

September 2002 Issue

Technology Toolbox: VB.NET, C#, .NET Framework

The introduction of multithreading into your VB6 application opens up a Pandora's box of synchronization and concurrency management issues. You have to worry about threads deadlocking while contesting for the same resources. You must synchronize access to objects by concurrent multiple threads. And you have to handle method re-entrance.

Figure 1. Multithreading Can Be Deadly.

Your first step in tackling such issues is to build thread-safe components by equipping them with mechanisms that prevent multiple threads from accessing them and corrupting the state of the objects. This helps, but it still doesn't prevent deadlocks, which occur when thread T1, which owns thread-safe resource R1, tries to access thread-safe resource R2 just as R2's owner, thread T2, tries to access R1 (see Figure 1). Multithreading defects are notoriously hard to isolate, reproduce, and eliminate. They often involve rare race conditions, and fixing one problem often introduces another. Before .NET, it was nontrivial to write robust, high-performance, multithreaded code. You needed a great deal of skill and discipline to succeed.

Back to top












Java Pro | Visual Studio Magazine | Windows Server System Magazine
.NET Magazine | Enterprise Architect | XML & Web Services Magazine
| | Discussions | Newsletters | FTP Home