My thoughts on Java Concurrency in Practice
Tags: java, concurrency, multithreading, books
Published: 2020-10-06 14:15:53

---
title: My thoughts on Java Concurrency in Practice
published: true
description: My review of the JCIP book
tags: java, concurrency, multithreading, books
cover_image: https://dev-to-uploads.s3.amazonaws.com/i/juzltbp5hawmuhsyq3jz.png
canonical_url: https://pmihaylov.com/my-thoughts-on-jcip/
---
<!-- wp:paragraph -->
<p>One of my <a rel="noreferrer noopener" href="https://pmihaylov.com/study-plan/" target="_blank">key goals this year</a> was to gain a good understanding of concurrency and multithreading. I've always had a tangent understanding of it at best. The book Java Concurrency in Practice was one of my first picks.</p>
<!-- /wp:paragraph -->

<!-- wp:paragraph -->
<p>Sure, I've used multithreading concepts like promises &amp; ajax in JavaScript before. I've also spawned go routines &amp; used mutexes in Go. But I've never felt I'm proficient enough to state that I have a good understanding of this subject.</p>
<!-- /wp:paragraph -->

<!-- wp:paragraph -->
<p>Hence, to bridge this gap in knowledge &amp; skills, I decided to invest in several concurrency related books &amp; courses. My intention was to start from JCIP and then move on to some additional courses. Initially, I felt that just reading this book won't be sufficient to understand the subject thoroughly.</p>
<!-- /wp:paragraph -->

<!-- wp:paragraph -->
<p>However, after going through this book I didn't bother looking into any other concurrency course at all. It is one of the most succinct and yet thorough books on a given topic that I've ever read.</p>
<!-- /wp:paragraph -->

<!-- wp:paragraph -->
<p>Additionally, I would recommend you to go through this book even if you're not using Java at all. It will give you a very profound understanding of whatever framework/mechanism your language of choice uses to tackle concurrency.</p>
<!-- /wp:paragraph -->

<!-- wp:paragraph -->
<p>Here's why...</p>
<!-- /wp:paragraph -->

<!-- wp:heading -->
<h2>Completeness</h2>
<!-- /wp:heading -->

<!-- wp:paragraph -->
<p>Java Concurrency in Practice is very thorough as it takes you from the basics you need to understand about concurrent programs all the way to the advanced topics, where the "dessert" is.</p>
<!-- /wp:paragraph -->

<!-- wp:paragraph -->
<p>However, it is also quite succinct as it doesn't drift into unnecessary details or complexities which aren't foundational to the subject.</p>
<!-- /wp:paragraph -->

<!-- wp:paragraph -->
<p>Many books and courses fail to achieve this. </p>
<!-- /wp:paragraph -->

<!-- wp:paragraph -->
<p>Some drift too much towards the theoretical and impractical. This makes the reader impatient and eventually, repels him from the book/course altogether. Most classical computer science books are like this, making them quite unattractive to novices and professionals alike.</p>
<!-- /wp:paragraph -->

<!-- wp:paragraph -->
<p>Others skip the foundations and simply focus on showing you "how it's done in X", where X is your favourite language. This kind of content might, at best, leave you hungrier than you were at the beginning. Worst case scenario, it might fool you into believing that "you know it all" and not study the subject further.</p>
<!-- /wp:paragraph -->

<!-- wp:paragraph -->
<p>There are very few courses &amp; books which achieve the golden balance between theory and practice.</p>
<!-- /wp:paragraph -->

<!-- wp:heading -->
<h2>Accessibility</h2>
<!-- /wp:heading -->

<!-- wp:paragraph -->
<p>Many books tend to be written in a very high-level way, skipping appropriate examples and using inaccessible language/terminology.</p>
<!-- /wp:paragraph -->

<!-- wp:paragraph -->
<p>These kinds of books require unnecessary additional attention in order to understand the context alone. This is quite deterring, especially when the reader realises that there are good alternative books on the subject half-way through.</p>
<!-- /wp:paragraph -->

<!-- wp:paragraph -->
<p>I avoid investing too much time in such books as reading those often contributes solely to "ego-reading" - giving you the prestige of a person who has read a book, which is considered a hard read. Understanding it is, though, is not a given.</p>
<!-- /wp:paragraph -->

<!-- wp:paragraph -->
<p>Now, I would consider Java Concurrency in Practice to be quite accessible and written in a very pedagogical way. It is full of examples to supplement the book &amp; aid you in "getting it".</p>
<!-- /wp:paragraph -->

<!-- wp:paragraph -->
<p>However, I wouldn't mark it as an easy read. It took me substantial effort to go through the book. I read through each chapter at least twice, while <a href="https://github.com/preslavmihaylov/booknotes">also taking notes</a> along the way.</p>
<!-- /wp:paragraph -->

<!-- wp:heading -->
<h2>Critique</h2>
<!-- /wp:heading -->

<!-- wp:heading {"level":3} -->
<h3>Lack of exercises</h3>
<!-- /wp:heading -->

<!-- wp:paragraph -->
<p>What the book unfortunately lacks is a set of good exercises. </p>
<!-- /wp:paragraph -->

<!-- wp:paragraph -->
<p>That would have been tremendously helpful as it supplements the read-through with "getting your hands dirty".</p>
<!-- /wp:paragraph -->

<!-- wp:paragraph -->
<p>This is why I had to tinker with the concepts in the IDE myself. This was the only way to back my theoretical understanding with enough practice.</p>
<!-- /wp:paragraph -->

<!-- wp:paragraph -->
<p>Google doesn't have any good suggestions either. <a href="https://www.reddit.com/r/learnprogramming/comments/9c6yo4/a_collection_of_projects_for_learning/">The top result</a> which pops up after you search for "concurrency projects" suggests some quite impractical projects. Projects such as creating your own concurrent hash map or implementing an atomic variable.</p>
<!-- /wp:paragraph -->

<!-- wp:paragraph -->
<p>I find this to be bad exercise advice as all these are concurrency primitives. Knowing how to implement them yourself is useless. </p>
<!-- /wp:paragraph -->

<!-- wp:paragraph -->
<p>They are already available out of the box and the book goes into enough depth to explain how they work.</p>
<!-- /wp:paragraph -->

<!-- wp:paragraph -->
<p>What's more, these exercises won't prepare you for an actual concurrency-related problem. Just because you know the concurrency primitives doesn't mean you can use them effectively.</p>
<!-- /wp:paragraph -->

<!-- wp:paragraph -->
<p>It would have been great if there were a couple of exercises in addition to each chapter. This would aid one in putting the concepts covered to practice.</p>
<!-- /wp:paragraph -->

<!-- wp:paragraph -->
<p>Although the book is lagging on this important point, fortunately it is still very well-made in all other aspects. Additionally, the provided examples help one bridge the gap even though you'll have to do some homework afterwards.</p>
<!-- /wp:paragraph -->

<!-- wp:heading {"level":3} -->
<h3>The book doesn't cover modern tools &amp; frameworks</h3>
<!-- /wp:heading -->

<!-- wp:paragraph -->
<p>The other critique I've often encountered is that the book doesn't cover the most modern practices in tackling concurrency. One could expect this given the book's age.</p>
<!-- /wp:paragraph -->

<!-- wp:paragraph -->
<p>However, I don't consider this to be that important. The book focuses on providing you with understanding of the fundamental concurrency concepts and problems.</p>
<!-- /wp:paragraph -->

<!-- wp:paragraph -->
<p>After you go through it, learning about the latest concurrency framework is a breeze. </p>
<!-- /wp:paragraph -->

<!-- wp:paragraph -->
<p>It is far more beneficial to understand the concepts covered in JCIP than it is to know the API of the latest framework.</p>
<!-- /wp:paragraph -->

<!-- wp:heading -->
<h2>How to approach this book</h2>
<!-- /wp:heading -->

<!-- wp:paragraph -->
<p>JCIP quite thoroughly covers the subject of concurrency and the author has also written it in an accessible way. However, this is not a "feel-good" book. It's not meant to be read from cover to cover. It is also not meant to be among the collection of 100 books you've read this year. It will definitely impede you in achieving that "paramount" goal.</p>
<!-- /wp:paragraph -->

<!-- wp:paragraph -->
<p>I'd advise readers to go through most chapters multiple times, especially the first five ones. In addition to that, I'd suggest one to take notes and even spend some time in the IDE tinkering with the concepts learnt.</p>
<!-- /wp:paragraph -->

<!-- wp:paragraph -->
<p>Have in mind that the author doesn't spend too much time explaining the APIs of the library routines they use. Don't be taken aback by this, simply keep a browser tab open, ready to look up the API documentation of the methods being used.</p>
<!-- /wp:paragraph -->

<!-- wp:paragraph -->
<p>Now, I wouldn't recommend these measures with any book as it is quite the time investment. But it's definitely worth it for this one. </p>
<!-- /wp:paragraph -->

<!-- wp:paragraph -->
<p>There are easier books &amp; courses on the subject out there. </p>
<!-- /wp:paragraph -->

<!-- wp:paragraph -->
<p>But almost all of them leave you with a "there's something missing" feeling. This makes you hop from one piece of content to another. </p>
<!-- /wp:paragraph -->

<!-- wp:paragraph -->
<p>This contributes to that never ending feeling that you don't have a good enough understanding of concurrency.</p>
<!-- /wp:paragraph -->

<!-- wp:paragraph -->
<p>Java Concurrency in Practice is not like that. It will leave you fulfilled &amp; confident that you understand the subject. After going through it, you'd rarely want to look to another book/course on the subject.</p>
<!-- /wp:paragraph -->

<!-- wp:paragraph -->
<p>But it does demand its share of attention and care. Don't pass on this opportunity, it is definitely worth it.</p>
<!-- /wp:paragraph -->

<!-- wp:heading -->
<h2>Prerequisites</h2>
<!-- /wp:heading -->

<!-- wp:paragraph -->
<p>Although JCIP is accessible, it still demands some backbone knowledge before starting it.</p>
<!-- /wp:paragraph -->

<!-- wp:paragraph -->
<p>Make sure that you are comfortable with an object-oriented programming language. You should also be comfortable opening the official documentation of an API over a stack overflow question.</p>
<!-- /wp:paragraph -->

<!-- wp:paragraph -->
<p>In addition to that, the book doesn't cover the very basics of multithreading.</p>
<!-- /wp:paragraph -->

<!-- wp:paragraph -->
<p>Concepts such as what a thread is, how it works or how to start one up. Make sure you spend a couple of days/weeks studying that beforehand.</p>
<!-- /wp:paragraph -->

<!-- wp:heading -->
<h2>Conclusion</h2>
<!-- /wp:heading -->

<!-- wp:paragraph -->
<p>Java Concurrency in Practice is one of the best books I've read on concurrency. I would recommend it to anyone, even if Java is not their language of choice.</p>
<!-- /wp:paragraph -->

<!-- wp:paragraph -->
<p>Its lack of exercises does force one to do some homework. But even so, the course makes most other content on concurrency obsolete.</p>
<!-- /wp:paragraph -->

<!-- wp:paragraph -->
<p>Due to this, JCIP does demand considerable attention, despite it being accessible, but it's definitely worth it.</p>
<!-- /wp:paragraph -->