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 a part of the Groovy distribution. Its main objective is to abstract away the complexity of parallel programming. GPars offers a number of parallel and concurrent programming tools that has almost no paragon in the JVM ecosystem. Most of the recipes will show how to execute tasks in parallel to save time and use resources at their best.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.144.30.62