threading in C# - C#线程
threading in C# Part 1 Getting Started Overview and Concepts ............................................................................................................. 3 How Threading Works ....................................................................................................... 6 Threads vs. Processes......................................................................................................... 6 When to Use Threads ................................................................................. ........................ 7 When Not to Use Threads .................................................................................................. 7 Creating and Starting Threads ................................................................................................... 8 Passing Data to ThreadStart ............................................................................................... 8 Naming Threads ............................................................................................................... 10 Foreground and Background Threads .............................................................................. 10 Thread Priority ................................................................................................................. 11 Exception Handling.......................................................................................................... 12 Part 2 Basic Synchronization ................................................................................14 Synchronization Essentials ...................................................................................................... 14 Blocking ........................................................................................................................... 15 Sleeping and Spinning...................................................................................................... 15 Joining a Thread ............................................................................................................... 16 Locking and Thread Safety...................................................................................................... 17 Choosing the Synchronization Object.............................................................................. 18 Nested Locking ................................................................................................................ 18 When to Lock ................................................................................................................... 19 Performance Considerations ............................................................................................ 19 Thread Safety ................................................................................................................... 20 Interrupt and Abort .................................................................................................................. 22 Interrupt ............................................................................................................................ 23 Abort................................................................................................................................. 23 Thread State ............................................................................................................................. 24 Wait Handles............................................................................................................................ 25 AutoResetEvent................................................................................................................ 26 ManualResetEvent ........................................................................................................... 30 Mutex ............................................................................................................................... 30
用户评论