4.3. Threading

Threading has been tweaked in .NET 4.0, with the thread pool switching to a lock-free data structure (apparently the queue used for work items is very similar to ConcurrentQueue). This new structure is more GC-friendly, faster, and more efficient.

Prior to .NET 4.0, the thread pool didn't have any information about the context in which the threads were created, which made it difficult to optimize (e.g., whether one thread depends on another). This situation changes in .NET 4.0 with a new class called Task that provide more information to the thread pool about the work to be performed, thus allowing it to make better optimizations. Tasks and other parallel and threading changes are covered in detail in Chapter 5.

Get Introducing .NET 4.0: with Visual Studio 2010 now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.