Groovy and Concurrency with GPars

This talk looks at using Groovy for writing multi-threaded, concurrent and parallel programs. We'll briefly review legacy Java techniques for writing such programs and some current best practices such as using immutable and persistent collections and leveraging some of Groovy's built-in AST transforms before jumping in and exploring the techniques offered by GPars.

Reviewed legacy Java techniques include multiple processes, multiple threads, the java.util.concurrent APIs and shared-state atomicity. We'll then explore some built-in Groovy functionality. We'll cover some useful AST transforms (Lazy, Synchronized, Immutable, WithReadLock and WithWriteLock). We'll also look at immutable and persistent collections.

GPars is a comprehensive library for parallel execution that provides a menu of options to the developer.We'll explore parallel collection support, examine Map/Reduce, Dataflow, Actors, composable asynchronous functions and the use of Agents and Active Objects. The different choices available have pros and cons depending on the circumstances. We'll provide some guidance.

We'll also briefly look at Multiverse (Software Transactional Memory) and JCSP, two emerging approaches that might appear more prominently in future versions of GPars. Then we'll wrap up with a brief look at testing multi-threaded programs.


About Paul King

Paul King, a member of the OCI Groovy team, leads ASERT, an organization based in Brisbane, Australia, which provides software development, training, and mentoring services to customers looking to embrace new technologies, harness best practices, and innovate. He has been contributing to open source projects for nearly 20 years and is an active committer on numerous projects, including Groovy. Paul speaks at international conferences, publishes in software magazines and journals, and is a co-author of Manning's best-seller, Groovy in Action.

More About Paul »