Introduction to Multi-threading in C#
24.1 INTRODUCTION AND OBJECTIVES
In this part of the book we introduce a number of design and software tools to help developers take advantage of the computing power of multi-core processors and multi-processor computers. These computers support parallel programming models. The main reason for writing parallel code is to improve the performance (called the speedup) of software programs. Another advantage is that multi-threaded code can also promote the responsiveness of applications in general.
We introduce a new programming model in this chapter. This is called the multi-threading model and it allows us to write software systems whose tasks can be carried out in parallel. This chapter is an introduction to multi-threaded programming techniques. We introduce the most important concepts that we need to understand in order to write multi-threaded applications in C#. A thread is a single sequential flow of control within a program. However, a thread itself is not a program. It cannot run on its own, but instead it runs within a program. A thread also has its own private data and it may be able to access shared data.
When would we create multi-threaded applications? The general answer is performance. Some common scenarios are: