C# for Java Programmers

Chapter 10: Multithreading

Introduction

In this chapter you will learn about the System.Threading namespace, which is one of the main class libraries provided by the .NET Framework for creating multithreaded programs. Multithreaded programs are similar to multitasking the ability to have more than one program working at the same time except that it s one step lower. Multithreaded applications give individual programs the ability to do multiple tasks at the same time.

The first part of the chapter will discuss threads and synchronization. Threads are lightweight processes used for multitasking within a single application. Just like Java, C# provides us with a simple way to build multithreaded programs and synchronizing resources accessed by multiple threads.

To end the chapter we will look at some of the trouble you can get into when you re writing multithreaded programs. We will look at conditions that can cause deadlocks and starvation to your running application, as well as how best to avoid these conditions.

Threads

Threads are an excellent way for programmers to parallelize multiple operations efficiently. Very much like multiple processes in multitasking operating systems, multiple threads within a single process can time-share critical resources such as the CPU and memory. Often threads are used to speed up response time to a program. For example, one thread can perform computations while another performs memory updates. The two threads would make the compute and update operations seem simultaneous.

Although threads generally tend to improve the performance of a program, they can negatively impact a program if there are not...

UNLIMITED FREE
ACCESS
TO THE WORLD'S BEST IDEAS

SUBMIT
Already a GlobalSpec user? Log in.

This is embarrasing...

An error occurred while processing the form. Please try again in a few minutes.

Customize Your GlobalSpec Experience

Category: Embedded Programming Software
Finish!
Privacy Policy

This is embarrasing...

An error occurred while processing the form. Please try again in a few minutes.