Chapter 10. Concurrent Programming in Groovy

In this chapter, we will cover:

  • Processing collections concurrently
  • Downloading files concurrently
  • Splitting a large task into smaller parallel jobs
  • Running tasks in parallel and asynchronously
  • Using actors to build message-based concurrency
  • Using STM to atomically update fields
  • Using dataflow variables for lazy evaluation

Introduction

The chapter you are about to read contains several recipes that deal with concurrent programming. We are going to examine a number of very efficient algorithm and paradigms to leverage the modern architecture of multi-core CPUs.

Most of the recipes in this chapter will use the awesome GPars (Groovy Parallel System) framework. GPars, which reached v1.0 at the end of 2012, is now ...

Get Groovy 2 Cookbook 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.