Multithreading, a very powerful technique, is essential for modern software development. Software users expect to work with a very responsive program that they don’t have to wait on, which is a very reasonable demand with the processor speeds that are currently available. Enter multithreading. Multithreading is the concept of having several different paths of code running at the same time.
When you introduce multithreading in your applications, you immediately make programming more complicated and add design time. You must know exactly what your application and all its threads are doing at all times. You have to account for deadlocks, race conditions and corrupting variable values. In this article we will examine the different methods in Visual Basic.Net to accomplish thread synchronization. We will learn what deadlocks and race conditions are and how to avoid these common problems with multithreading.
System Requirements
I will assume that you already have knowledge of basic threading in Visual Basic.Net. You should know how to create threads and know how to do basic threading operations like Join and Sleep. A copy of Visual Studio.Net is required to run the code samples and see the output. The code was written with Visual Studio.Net using version 1.0 of the .Net Framework with service pack 2.
Case Study Structure
This case study has three main parts. Multithreading requires a technique called synchronization to eliminate the problems described above so we will first take a brief look at what synchronization is. Then an in-depth look at all methods available in Visual Basic.Net for synchronization will be presented where you will learn how to correctly synchronize a multithreaded application. After this, a look at Window’s Form synchronization and threading apartment styles will show the differences a programmer must handle between standard synchronization and visual GUI synchronization.
Comments