Seven Concurrency Models in Seven Weeks
eBook - ePub

Seven Concurrency Models in Seven Weeks

When Threads Unravel

  1. 296 pages
  2. English
  3. ePUB (mobile friendly)
  4. Available on iOS & Android
eBook - ePub

Seven Concurrency Models in Seven Weeks

When Threads Unravel

About this book

This book will show you how to exploit different parallel architectures to improve your code's performance, scalability, and resilience. You'll learn about seven concurrency models: threads and locks, functional programming, separating identity and state, actors, sequential processes, data parallelism, and the lambda architecture.

Learn about the perils of traditional threads and locks programming and how to overcome them through careful design and by working with the standard library. See how actors enable software running on geographically distributed computers to collaborate, handle failure, and create systems that stay up 24/7/365. Understand why shared mutable state is the enemy of robust concurrent code, and see how functional programming together with technologies such as Software Transactional Memory ( STM ) and automatic parallelism help you tame it.

You'll learn about the untapped potential within every GPU and how GPGPU software can unleash it. You'll see how to use MapReduce to harness massive clusters to solve previously intractable problems, and how, in concert with Stream Processing, big data can be tamed.

With an understanding of the strengths and weaknesses of each of the different models and hardware architectures, you'll be empowered to tackle any problem with confidence.

Q&A with Author Paul Butcher:

Q: Concurrency and parallelism aren't new; why are they such hot topics now?

A: Because processors have stopped getting faster. You can no longer make your code run faster by simply using newer hardware. These days, if you need more performance, you need to exploit multiple cores, and that means exploiting parallelism.

Q: Is it just about exploiting multiple cores?

A: Not at all. Concurrency also allows you to create software that's responsive, fault-tolerant, geographically distributed, and (if you use the right approach) simpler than traditional sequential software.

Q: Aren't threads and locks enough?

A: Getting multi-threaded code right is really hard (much harder than most people realize). There are better choices available that are easier to understand and easier to debug. And threads and locks give you no help when it comes to distribution, fault-tolerance, or exploiting data parallel architectures.

Q: Data parallelism? What's that?

A: We tend to think of parallel computer architecture in terms of multiple cores, but that's just one of the ways to implement parallelism. You have a supercomputer hidden in your laptop—your graphics card is a very sophisticated data parallel processor. You can use data parallel programming techniques to unlock its potential, and when you do, its performance will blow you away.

Q: How does concurrency help with fault tolerance?

A: If your software is running on a single computer, and that computer fails, there's no way for your software to recover. So true fault-tolerance necessarily requires more than one computer, and that means that it has to be concurrent. Sequential software can never be as resilient as concurrent software.

Q: How will this affect me?

A: Concurrency is everywhere—even client-side web programming is going concurrent. So no matter what kind of software you write, it's going to be an increasingly important aspect of what you do. By giving you an overview of the concurrency landscape, I hope that this book will help you tackle your future projects with confidence.

Top 5 tips

1. Know where the dragons lie in wait.

Threads and locks are the most popular approach to concurrency, but they're very difficult to get right. Do you know how to avoid deadlock? Livelock? Do you know what the memory model says about when it's safe for one thread to read changes made by another? Or why you shouldn't call a foreign function while holding a lock?

2. Understand the difference between parallelism and concurrency.

Although they're often confused, parallelism and concurrency are different things. Concurrency is an aspect of the problem domain—your code needs to handle multiple simultaneous (or near simultaneous) events. Parallelism, by contrast, is an aspect of the solution domain—you want to make your program run faster by processing different portions of the problem in parallel. Some approaches are applicable to concurrency, some to parallelism, and some to both. Understand which you're faced with and choose the right tool for the job.

3. Brush up your functional programming.

You don't need to write functional programs to write concurrent software, but even if you're using a traditional imperative language like Java, understanding the functional principles of immutable data and referential transparency will be incredibly helpful.

4. Remember that it's not just about multiple cores.

Although the resurgence of interest in concurrency is a result of the multicore crisis, concurrency is about much more than just exploiting multiple cores. Concurrency also allows you to create software that's responsive, fault-tolerant, geographically distributed, and (if you use the right approach) simpler than traditional software.

5. Don't be daunted.

Concurrent programming has a fearsome reputation, but that mostly derives from the problems with threads and locks. If you use the right tools for the job, concurrent programming can be simple, expressive and even fun.

Frequently asked questions

Yes, you can cancel anytime from the Subscription tab in your account settings on the Perlego website. Your subscription will stay active until the end of your current billing period. Learn how to cancel your subscription.
At the moment all of our mobile-responsive ePub books are available to download via the app. Most of our PDFs are also available to download and we're working on making the final remaining ones downloadable now. Learn more here.
Perlego offers two plans: Essential and Complete
  • Essential is ideal for learners and professionals who enjoy exploring a wide range of subjects. Access the Essential Library with 800,000+ trusted titles and best-sellers across business, personal growth, and the humanities. Includes unlimited reading time and Standard Read Aloud voice.
  • Complete: Perfect for advanced learners and researchers needing full, unrestricted access. Unlock 1.4M+ books across hundreds of subjects, including academic and specialized titles. The Complete Plan also includes advanced features like Premium Read Aloud and Research Assistant.
Both plans are available with monthly, semester, or annual billing cycles.
We are an online textbook subscription service, where you can get access to an entire online library for less than the price of a single book per month. With over 1 million books across 1000+ topics, we’ve got you covered! Learn more here.
Look out for the read-aloud symbol on your next book to see if you can listen to it. The read-aloud tool reads text aloud for you, highlighting the text as it is being read. You can pause it, speed it up and slow it down. Learn more here.
Yes! You can use the Perlego app on both iOS or Android devices to read anytime, anywhere — even offline. Perfect for commutes or when you’re on the go.
Please note we cannot support devices running on iOS 13 and Android 7 or earlier. Learn more about using the app.
Yes, you can access Seven Concurrency Models in Seven Weeks by Paul Butcher in PDF and/or ePUB format, as well as other popular books in Computer Science & Computer Science General. We have over one million books available in our catalogue for you to explore.

Table of contents

  1. Seven Concurrency Models in Seven Weeks
  2. For the Best Reading Experience...
  3. Table of Contents
  4. Early Praise for Seven Concurrency Models in Seven Weeks
  5. Foreword
  6. Acknowledgments
  7. Preface
  8. Chapter 1: Introduction
  9. Chapter 2: Threads and Locks
  10. Chapter 3: Functional Programming
  11. Chapter 4: The Clojure Way— Separating Identity from State
  12. Chapter 5: Actors
  13. Chapter 6: Communicating Sequential Processes
  14. Chapter 7: Data Parallelism
  15. Chapter 8: The Lambda Architecture
  16. Chapter 9: Wrapping Up
  17. Bibliography