您好,欢迎光临本网站![请登录][注册会员]  
文件名称: 多线程开发文档
  所属分类: .Net
  开发工具:
  文件大小: 1mb
  下载次数: 0
  上传时间: 2013-05-30
  提 供 者: dabi*****
 详细说明: 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 Misu ses ............................................................. 8 Creating and Starting Threads ........................................................................ 8 Passing Data to a Thread ...................................................................... 9 Naming Threads ................................................................................. 11 Foreground and Background Threads ................................................ 11 Thread Priority.................................................................................... 12 Exception Handling ............................................................................ 12 Thread Pooling .............................................................................................. 14 Entering the Thread Pool via TPL ...................................................... 15 Entering the Thread Pool 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 ......................................................................................................... 21 Monitor.Enter and Monitor.Exit ......................................................... 22 Choosing the Synchronization Object ................................................ 23 When to Lock ..................................................................................... 23 Locking and Atomicity ....................................................................... 24 Nested Locking ................................................................................... 24 Deadlocks ........................................................................................... 25 Performance ........................................................................................ 26 Mutex .................................................................................................. 26 Semaphore .......................................................................................... 27 © 2006-2010 Joseph Albahari, O’Reilly Media, Inc. All rights reserved. www.albahari.com/threading/ 2 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 .................................................................................. 33 ManualResetEvent .............................................................................. 37 CountdownEvent ................................................................................ 38 Creating a Cross-Process EventWaitHandle ...................................... 39 Wait Handles and the Thread Pool ..................................................... 39 WaitAny, WaitAll, and SignalAndWait ............................................. 40 Synchronization Contexts ............................................................................. 41 Reentrancy .......................................................................................... 43 Part 3: Using Threads .................................................................... 44 The Event-Based Asynchronous Pattern ...................................................... 44 BackgroundWorker ....................................................................................... 45 Using BackgroundWorker .................................................................. 45 Subclassing BackgroundWorker ........................................................ 47 Interrupt and Abort ....................................................................................... 48 Interrupt .............................................................................................. 49 Abort ................................................................................................... 49 Safe Cancellation .......................................................................................... 50 Cancellation Tokens ........................................................................... 51 Lazy Initialization ......................................................................................... 52 Lazy ............................................................................................. 53 LazyInitializer..................................................................................... 53 Thread-Local Storage ................................................................................... 54 [ThreadStatic] ..................................................................................... 54 ThreadLocal ................................................................................. 55 GetData and SetData .......................................................................... 55 Timers ........................................................................................................... 56 Multithreaded Timers ......................................................................... 56 Single-Threaded Timers ..................................................................... 58 Part 4: Advanced Topics ............................................................... 59 Nonblocking Synchronization ...................................................................... 59 Memory Barriers and Volatility ......................................................... 59 Interlocked .......................................................................................... 63 Signaling with Wait and Pulse ...................................................................... 65 How to Use Wait and Pulse ................................................................ 65 Producer/Consumer Queue ................................................................. 67 Wait Timeouts .................................................................................... 70 Two-Way Signaling and Races .......................................................... 71 Simulating Wait Handles .................................................................... 72 Writing a CountdownEvent ................................................................ 74 Thread Rendezvous ............................................................................ 75 © 2006-2010 Joseph Albahari, O’Reilly Media, Inc. All rights reserved. www.albahari.com/threading/ 3 The Barrier Class .......................................................................................... 75 Reader/Writer Locks ..................................................................................... 77 Upgradeable Locks and Recursion ..................................................... 78 Suspend and Resume .................................................................................... 80 Aborting Threads .......................................................................................... 80 Complications with Thread.Abort ...................................................... 82 Ending Application Domains ............................................................. 83 Ending Processes ................................................................................ 84 Part 5: Parallel Programming ........................................................ 85 Parallel Programming ................................................................................... 85 Why PFX? .................................................................................................... 85 PFX Concepts ..................................................................................... 86 PFX Components................................................................................ 86 When to Use PFX ............................................................................... 87 PLINQ ........................................................................................................... 87 Parallel Execution Ballistics ............................................................... 89 PLINQ and Ordering .......................................................................... 89 PLINQ Limitations ............................................................................. 90 Example: Parallel Spellchecker .......................................................... 90 Functional Purity ................................................................................ 92 Calling Blocking or I/O-Intensive Functions ..................................... 92 Cancellation ........................................................................................ 94 Optimizing PLINQ ............................................................................. 94 Parallelizing Custom Aggregations .................................................... 96 The Parallel Class ....................................................................................... 100 Parallel.Invoke .................................................................................. 100 Parallel.For and Parallel.ForEach ..................................................... 100 Task Parallelism .......................................................................................... 105 Creating and Starting Tasks .............................................................. 105 Waiting on Tasks .............................................................................. 107 Exception-Handling Tasks ............................................................... 108 Canceling Tasks ................................................................................ 109 Continuations .................................................................................... 110 Task Schedulers and UIs .................................................................. 113 TaskFactory ...................................................................................... 114 TaskCompletionSource .................................................................... 114 Working with AggregateException ............................................................ 115 Flatten and Handle ............................................................................ 116 Concurrent Collections ............................................................................... 117 IProducerConsumerCollection .................................................. 117 ConcurrentBag ........................................................................... 118 BlockingCollection .................................................................... 119 SpinLock and SpinWait .............................................................................. 121 SpinLock........................................................................................... 121 SpinWait ........................................................................................... 122 ...展开收缩
(系统自动生成,下载前可以参看下载内容)

下载文件列表

相关说明

  • 本站资源为会员上传分享交流与学习,如有侵犯您的权益,请联系我们删除.
  • 本站是交换下载平台,提供交流渠道,下载内容来自于网络,除下载问题外,其它问题请自行百度
  • 本站已设置防盗链,请勿用迅雷、QQ旋风等多线程下载软件下载资源,下载后用WinRAR最新版进行解压.
  • 如果您发现内容无法下载,请稍后再次尝试;或者到消费记录里找到下载记录反馈给我们.
  • 下载后发现下载的内容跟说明不相乎,请到消费记录里找到下载记录反馈给我们,经确认后退回积分.
  • 如下载前有疑问,可以通过点击"提供者"的名字,查看对方的联系方式,联系对方咨询.
 相关搜索: 多线程
 输入关键字,在本站1000多万海量源码库中尽情搜索: