Threading in c#

Solo disponible en BuenasTareas
  • Páginas : 180 (44907 palabras )
  • Descarga(s) : 0
  • Publicado : 1 de noviembre de 2010
Leer documento completo
Vista previa del texto
Threading in C#
Joseph Albahari
Last updated 2010-8-13

Interested in a book on C# and .NET by the same author?
See www.albahari.com/nutshell/

Table of Contents
Part 1: Getting Started ..................................................................... 4
Introduction and Concepts .............................................................................. 4 Join and Sleep....................................................................................... 6 How Threading Works ......................................................................... 7 Threads vs Processes ............................................................................ 7 Threading’s Uses and Misuses ............................................................. 8 Creating and StartingThreads ........................................................................ 8 Passing Data to a Thread ...................................................................... 9 Naming Threads ................................................................................. 11 Foreground and Background Threads ................................................ 11 ThreadPriority.................................................................................... 12 Exception Handling ............................................................................ 12 Thread Pooling.............................................................................................. 14 Entering the Thread Pool via TPL ...................................................... 15 Entering the ThreadPool Without TPL .............................................. 16 Optimizing the Thread Pool ............................................................... 17

Part 2: Basic Synchronization....................................................... 19
Synchronization Essentials ........................................................................... 19 Blocking............................................................................................. 19 Blocking Versus Spinning .................................................................. 20 ThreadState ......................................................................................... 20 Locking ......................................................................................................... 21Monitor.Enter and Monitor.Exit ......................................................... 22 Choosing the Synchronization Object ................................................ 23 When to Lock ..................................................................................... 23 Locking and Atomicity ....................................................................... 24 NestedLocking................................................................................... 24 Deadlocks ........................................................................................... 25 Performance........................................................................................ 26 Mutex.................................................................................................. 26Semaphore .......................................................................................... 27

© 2006-2010 Joseph Albahari, O’Reilly Media, Inc. All rights reserved. www.albahari.com/threading/

1

Thread Safety ................................................................................................ 28 Thread Safety and .NET Framework Types....................................... 28 Thread Safety in Application Servers................................................. 30 Rich Client Applications and Thread Affinity ................................... 30 Immutable Objects.............................................................................. 32 Signaling with Event Wait Handles .............................................................. 33 AutoResetEvent...
tracking img