Concurrent Programming on Windows

Concurrent Programming on Windows

5.0 1
by Joe Duffy

View All Available Formats & Editions

“When you begin using multi-threading throughout an application, the importance of clean architecture and design is critical. . . . This places an emphasis on understanding not only the platform’s capabilities but also emerging best practices. Joe does a great job interspersing best practices alongside theory throughout his book.”


“When you begin using multi-threading throughout an application, the importance of clean architecture and design is critical. . . . This places an emphasis on understanding not only the platform’s capabilities but also emerging best practices. Joe does a great job interspersing best practices alongside theory throughout his book.”

– From the Foreword by Craig Mundie, Chief Research and Strategy Officer, Microsoft Corporation


Author Joe Duffy has risen to the challenge of explaining how to write software that takes full advantage of concurrency and hardware parallelism. In Concurrent Programming on Windows, he explains how to design, implement, and maintain large-scale concurrent programs, primarily using C# and C++ for Windows.


Duffy aims to give application, system, and library developers the tools and techniques needed to write efficient, safe code for multicore processors. This is important not only for the kinds of problems where concurrency is inherent and easily exploitable—such as server applications, compute-intensive image manipulation, financial analysis, simulations, and AI algorithms—but also for problems that can be speeded up using parallelism but require more effort—such as math libraries, sort routines, report generation, XML manipulation, and stream processing algorithms.


Concurrent Programming on Windows has four major sections: The first introduces concurrency at a high level, followed by a section that focuses on the fundamental platform features, inner workings, and API details. Next, there is a section that describes common patterns, best practices, algorithms, and data structures that emerge while writing concurrent software. The final section covers many of the common system-wide architectural and process concerns of concurrent programming.


This is the only book you’ll need in order to learn the best practices and common patterns for programming with concurrency on Windows and .NET.

Editorial Reviews

From the Publisher

“I have been fascinated with concurrency ever since I added threading support to the Common Language Runtime a decade ago. That’s also where I met Joe, who is a world expert on this topic. These days, concurrency is a first-order concern for practically all developers. Thank goodness for Joe’s book. It is a tour de force and I shall rely on it for many years to come.”

—Chris Brumme, Distinguished Engineer, Microsoft

“I first met Joe when we were both working with the Microsoft CLR team. At that time, we had several discussions about threading and it was apparent that he was as passionate about this subject as I was. Later, Joe transitioned to Microsoft’s Parallel Computing Platform team where a lot of his good ideas about threading could come to fruition. Most threading and concurrency books that I have come across contain information that is incorrect and explains how to solve contrived problems that good architecture would never get you into in the first place. Joe’s book is one of the very few books that I respect on the matter, and this respect comes from knowing Joe’s knowledge, experience, and his ability to explain concepts.”

—Jeffrey Richter, Wintellect

“There are few areas in computing that are as important, or shrouded in mystery, as concurrency. It’s not simple, and Duffy doesn’t claim to make it so—but armed with the right information and excellent advice, creating correct and highly scalable systems is at least possible. Every self-respecting Windows developer should read this book.”

—Jonathan Skeet, Software Engineer, Clearswift

“What I love about this book is that it is both comprehensive in its coverage of concurrency on the Windows platform, as well as very practical in its presentation of techniques immediately applicable to real-world software development. Joe’s book is a ‘must have’ resource for anyone building native or managed code Windows applications that leverage concurrency!”

—Steve Teixeira, Product Unit Manager, Parallel Computing Platform, Microsoft Corporation

“This book is a fabulous compendium of both theoretical knowledge and practical guidance on writing effective concurrent applications. Joe Duffy is not only a preeminent expert in the art of developing parallel applications for Windows, he’s also a true student of the art of writing. For this book, he has combined those two skill sets to create what deserves and is destined to be a long-standing classic in developers’ hands everywhere.”

—Stephen Toub, Program Manager Lead, Parallel Computing Platform, Microsoft

“As chip designers run out of ways to make the individual chip faster, they have moved towards adding parallel compute capacity instead. Consumer PCs with multiple cores are now commonplace. We are at an inflection point where improved performance will no longer come from faster chips but rather from our ability as software developers to exploit concurrency. Understanding the concepts of concurrent programming and how to write concurrent code has therefore become a crucial part of writing successful software. With Concurrent Programming on Windows, Joe Duffy has done a great job explaining concurrent concepts from the fundamentals through advanced techniques. The detailed descriptions of algorithms and their interaction with the underlying hardware turn a complicated subject into something very approachable. This book is the perfect companion to have at your side while writing concurrent software for Windows.”

—Jason Zander, General Manager, Visual Studio, Microsoft

Product Details

Pearson Education
Publication date:
Microsoft Windows Development Series
Sold by:
Barnes & Noble
File size:
3 MB

Read an Excerpt

I began writing this book towards the end of 2005. At the time, dual-core processors were becoming standard on the mainstream PC's that ordinary (non-programmer) consumers were buying, and a small number of people in industry had begun to make noise about the impending concurrency problem. (Herb Sutter's The Free Lunch is Over paper immediately comes to mind.) The problem people were worried about, of course, was that the software of the past was not written in a way that would allow it to naturally exploit that additional compute power. Contrast that with the never-ending increase in clock speeds. No more free lunch indeed.

It seemed to me that concurrency was going to be an important part of every software developer's job somewhere down the road and that a book like this would be important and useful. Just over two years later, the impact is beginning to ripple up from the operating system, through the libraries, and on up to applications themselves.

This was about the same time I had wrapped up prototyping a small side-project on which I had been burning the midnight oil for the previous six months: Parallel Language Integrated Query (PLINQ). The PLINQ project was a conduit for me to explore the intricacies of concurrency, multi-core, and specifically how parallelism might be used in real-world, everyday programs. I used it as a tool to figure out where the platform was lacking. This was in addition to spending my day job at Microsoft focused on software transactional memory (STM), a technology that in the intervening two years has become somewhat of an industry buzzword. Needless to say, I had become pretty entrenched in all topicsconcurrency. What better way to get entrenched even further than to write a book on the subject?

As I worked on all of these projects, and eventually PLINQ grew into Parallel Extensions to the .NET Framework, I was amazed at how few good books on Windows concurrency were available. I remember time and time again being astonished or amazed at some intricate and esoteric bit of concurrency-related information, jotting it down, and earmarking it for inclusion in this book. I only wished somebody had written it down before me, so that I didn't need to scour it from numerous sources: hallway conversations, long nights of pouring over Windows and CLR source code, and reading and rereading countless Microsoft employee blogs. But the best books on the topic dated back to the early '90s and, while still really good, focused too much on the mechanics and not on how to structure parallel programs, implement parallel algorithms, deal with concurrency hazards, and other important concepts. Everything else targeted academics and researchers, and not application, system, and library developers.

I set out to write a book that I'd have found fascinating and a useful way to shortcut all of the random bits of information I had to learn throughout. Although it took me a surprisingly long two-and-a-half years to finish this book (!), the state of the art has evolved slowly, and the state of good books on the topic hasn't changed much either. The result of my efforts, I hope, is a new book that is down-to-earth and useful, but still full of very deep technical information. It is for any Windows or .NET developer who believes that concurrency is going to be a fundamental requirement of all software somewhere down the road, as all industry trends seem to imply.

I look forward to kicking back and enjoying this book. And I sincerely hope you do too.Book Structure

I've structured the book into four major parts. The first, Concepts, introduces concurrency at a high level without going too deep into any one topic. The next part, Mechanisms, focuses squarely on the fundamental platform features, inner workings, and API details. After that, the part on Techniques describes common patterns, best practices, algorithms, and data structures that emerge while writing concurrent software. The fourth part, Systems, covers many of the systemwide architectural and process concerns that frequently arise. There is a progression here. Concepts is first because it develops a basic understanding of concurrency in general. Understanding the content in Techniques would be difficult without a solid understanding of the Mechanisms, and similarly, building real Systems would be impossible without understanding the rest. There is also a collection of Appendices at the end.Code Requirements

To run code found in this book, you'll need to download some free pieces of software:

  • Microsoft Windows SDK. This includes the Microsoft C++ compiler and relevant platform headers and libraries. The latest versions as of this writing are the Windows Vista and Server 2008 SDKs.
  • Microsoft .NET Framework SDK. This includes the Microsoft C# and Visual Basic compilers, and relevant framework libraries. The latest version as of this writing is the .NET Framework 3.5 SDK.

Both can be found on MSDN:

In addition, it's highly recommended that you consider using Visual Studio. This is not required—and in fact, much of the code in this book was written in emacs—but provides for a more seamless development and debugging experience. Visual Studio 2008 Express Edition can be downloaded for free, although it lacks many useful capabilities such as performance profiling.

Lastly, the Debugging Tools for Windows package—which includes the popular WINDBG debugging utility—might also come in handy, particularly if you don't have Visual Studio. It is freely downloadable from Similarly, the Sysinternals utilities available from are quite useful for inspecting aspects of the Windows OS.

A companion website for the book will be available simultaneous with publication of the book.

Joe Duffy
June 2008

Meet the Author

Joe Duffy is the development lead, architect, and founder of the Parallel Extensions to the .NET Framework team at Microsoft. In addition to hacking code and managing a team of developers, he works on long-term vision and incubation efforts, such as language and type system support for concurrency safety. He previously worked on the Common Language Runtime team. Joe blogs regularly at

Customer Reviews

Average Review:

Write a Review

and post it to your social network


Most Helpful Customer Reviews

See all customer reviews >

Concurrent Programming on Windows 5 out of 5 based on 0 ratings. 1 reviews.
Anonymous More than 1 year ago