This talk looks at using Groovy for writing multi-threaded, concurrent and parallel programs. We’ll briefly look at leveraging legacy Java techniques such as multiple processes, multiple threads, the java.util.concurrent APIs and shared-state atomicity. We’ll then look as some useful AST transforms in core Groovy (Lazy, Synchronized, Immutable, WithReadLock and WithWriteLock) before divign headlong into GPars. GPars is a comprehensive library for parallel execution that provides a menu of options to the developer.
The different choices available have pros and cons depending on the circumstances. We’ll look at the parallel collection support and the optional transparent way to use that support. Then we’ll examine Map/Reduce. We’ll also look at the DataFlow approach to achieving concurrency, the Actors approach, the use of composable asynchronous functions and the use of Agents and Active Objects. Finally, we’ll peek 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.