Summary

We had a whirlwind tour of concurrency mechanisms. It started with the producer/consumer pipeline of Unix. Then we saw the inherent principles behind the pipeline, namely decoupling and each tool doing at least one thing. This is the essential Unix philosophy.

We looked at the recursive grep worker as an example. After the pipeline solution, we looked at the producer/consumer implementation in Java. We looked at the problems of performing multithreading by ourselves. We also saw how we need to take extreme care not to introduce race conditions.

Races can take place when there is a possibility of the same state getting updated by multiple threads. We saw one example of a leaky abstraction and how immutability helps us gain the ground back. ...

Get Scala Functional Programming Patterns 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.