Avoiding Contention Issues

One big design problem exists with multithreaded applications: thread contention. When you start creating threads, you are simultaneously creating the potential for a conflict any time two or more threads try to access a resource like a file, area of memory, object, and so on. Sharing resources and running threads concurrently are certainly two of the reasons why you would choose to multithread your application in the first place; you just need to be aware of the potential problems this introduces, and actively work to mitigate or eliminate these problems in your code.

Races and Deadlocks

To give us a background for discussing the kinds of problems you can experience with ill- behaved resource access, let's consider ...

Get Visual Basic® Programmer's Guide to the .NET Framework Class Library 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.