HN Books @HNBooksMonth

The best books of Hacker News.

Hacker News Comments on
Java Concurrency in Practice

Brian Goetz, Tim Peierls, Joshua Bloch, Joseph Bowbeer, David Holmes, Doug Lea · 13 HN comments
HN Books has aggregated all Hacker News stories and comments that mention "Java Concurrency in Practice" by Brian Goetz, Tim Peierls, Joshua Bloch, Joseph Bowbeer, David Holmes, Doug Lea.
View on Amazon [↗]
HN Books may receive an affiliate commission when you make purchases on sites after clicking through links on this page.
Amazon Summary
As processors become faster and multiprocessor systems become cheaper, the need to take advantage of multithreading in order to achieve full hardware resource utilization only increases the importance of being able to incorporate concurrency in a wide variety of application categories. For many developers, concurrency remains a mystery. Developing, testing, and debugging multithreaded programs is extremely difficult because concurrency hazards do not manifest themselves uniformly or reliably. This book is intended to be neither an introduction to concurrency (any threading chapter in an "intro" book does that) nor is it an encyclopedic reference of All Things Concurrency (that would be Doug Lea's Concurrent Programming in Java). Instead, this title is a combination of concepts, guidelines, and examples intended to assist developers in the difficult process of understanding concurrency and its new tools in J2SE 5.0. Filled with contributions from Java gurus such as Josh Bloch, David Holmes, and Doug Lea, this book provides any Java programmers with the basic building blocks they need to gain a basic understanding of concurrency and its benefits.
HN Books Rankings

Hacker News Stories and Comments

All the comments and stories posted to Hacker News that reference this book.
Idk about GP, but one book I highly recommend is Java Concurrency in Practice - https://www.amazon.com/Java-Concurrency-Practice-Brian-Goetz...

It's old, but the material holds up well since it covers a lot of fundamentals

nobleach
I have the book. I've tried reading it several times. I just can't get into it. My major complaint is that it gives a ton of code examples and then "don't do this" is written under it. So one has to be extremely alert at all times while reading through the book. It dives right into the subject as if one has already been writing threaded code. Perhaps that's the target audience.
johnnycerberus
I also recommend it, a little bit old because it doesn't cover new features but the fundamentals are strong, Brian Goetz really did a great job.
robto
We were an all-Java shop and we were considering how to make our application a SAAS cloud application. Our senior engineers read this book. They all agreed that it was very educational, but the conclusion was that Java concurrency in practice has too many footguns, and so we ended up adopting Clojure.

I think modern Java has better support for it, but if you've got mutable state spread throughout your application you're going to have a hard time no matter what.

wging
Rich Hickey is supposed to have said that he created Clojure because he was tired of telling people to read that book.

Best I can find as a source for now is https://www.youtube.com/watch?v=2y5Pv4yN0b0 -- I thought there was a link somewhere to Hickey himself saying this, but can't find it.

secondcoming
> senior engineers read this book

How does one become a senior engineer if you don't understand concurrency?

Mutable state is most easily solved by having cpoies of everything, but then that's a tradeoff between performance and infrastructure/resource costs, but I guess that if you're in an all-Java shop that isn't much of an issue.

flqn
Reading a book on the basics doesn't mean you don't have a grasp of them. I'd argue that refreshing your knowledge on things is a mark of a good engineer, regardless of seniority.
Try these as a starting point:

- Think Java (programming, foundational; free) https://greenteapress.com/wp/think-java/

- Think Data Structures (programming, foundational; free) https://greenteapress.com/wp/think-data-structures/

- Effective Java (classic) https://www.amazon.co.uk/Effective-Java-Joshua-Bloch/dp/0134...

- Java Concurrency in Practice (classic) https://www.amazon.co.uk/Java-Concurrency-Practice-Brian-Goe...

- Continuous Delivery in Java (essential) https://www.amazon.co.uk/Continuous-Delivery-Java-Daniel-Bry...

In the talk "Clojure Concurrency" [1], Rich Hickey demands that everyone in the room read "Java Concurrency in Practice" [2]. "It will scare the crap out of you."

[1] https://youtu.be/dGVqrGmwOAw?t=23m57s [2] https://www.amazon.com/Java-Concurrency-Practice-Brian-Goetz...

muxator
What do that comment mean?
peheje
Java 8 released march 2014. Youtube video published december 2012. Book originally published 2006. What am I missing?
cle
The fact Java 8 streams only address a tiny sliver of the concurrency problems addressed by JCIP.

In practice, Java 8 parallel streams are generally discouraged outside of raw number crunching, which is rarely where we need parallel speedup anyway.

Coding_Cat
raw number crunching doesn't parallel speedup(!)?
phdelightful
The parent might be saying that we already have some good techniques for speeding up raw number crunching in parallel, so it's not as desirable to add yet another.
cle
Didn't say that, I said that we rarely need parallelization for raw number crunching. Developers use parallelization for coordinating expensive IO way more often, and Java 8 streams solve almost nothing for that. Still need to know and worry about other Java concurrency primitives like volatiles, monitors, thread pools, etc. and all their pitfalls (race conditions, deadlocks, etc.).

You should still read JCIP, it is still highly relevant in Java-land. Java 8 streams solved almost nothing in terms of concurrency (in fact they probably created more problems than they solved...). You should still be scared of concurrency in general, and particularly in Java. And you should definitely consider a different language with more sane and modern concurrency primitives if you really need concurrency.

peheje
Ah ok. I was confused by the reponse to slaymaker1907 who recommended Streams directly, as it didn't seem to address the Stream API. I guess many of the challenges of concurrent computing still applies here.

When else do we need parallel speedup?

Wow, that's actually kinda tough to answer. There's been a LOT of changes in the Java world in the last 10 years - as you might guess. And I mean both in terms of the language itself, and the tooling and ecosystem as far as libraries and frameworks, etc.

The answer also depends a bit on what exactly you want to do. If you're mainly interested in web apps, it's one thing, "big data" is another world altogether, mobile (Android) has its own ecosystem, etc.

All of that said, here are some thoughts:

Generics and the newer Collections related stuff is one area that changed a lot. There's online documentation at:

https://docs.oracle.com/javase/tutorial/java/generics/index....

https://docs.oracle.com/javase/tutorial/java/generics/types....

and a decent, if somewhat older, book is http://shop.oreilly.com/product/9780596527754.do

Then there's the newer concurrency stuff that came along in the Java 5 / Java 6 era. Fork/Join, Executors, etc. Java Concurrency In Practice should still be useful to you, even though it is, again, a little bit dated now.

https://www.amazon.com/Java-Concurrency-Practice-Brian-Goetz...

To get started with the Java 8 stuff, a book like "Java 8 in Action" would be good.

https://www.amazon.com/Java-Action-Lambdas-functional-style-...

Another good intro the Java 8 era stuff is

https://www.amazon.com/Beginning-Java-Language-Features-Expr...

And to make it even harder, Java 9 just dropped, so there's even more new stuff. I just picked up this book myself, but haven't had a lot of time to dig into it yet.

https://www.amazon.com/Java-Programmers-4th-Deitel-Developer...

For frameworks, Spring and Hibernate are both still popular and it wouldn't hurt to brush up on both of those. Spring Boot in particular has caught on for a lot of Java developers.

https://www.amazon.com/Spring-Boot-Action-Craig-Walls/dp/161...

Also, Tomcat is still very popular for hosting java Web applications and services of various sorts. JBoss / Wildfly is still around, but JEE (as J2EE is now known) is not as popular as in the past (even though it has actually improved a LOT).

Play and Dropwizard are two more frameworks you might want to familiarize yourself with

https://www.playframework.com/

http://www.dropwizard.io/1.1.4/docs/

In terms of tools, Eclipse is still popular, IntelliJ is probably the most popular Java IDE these days, and Netbeans seems to have faded from view a bit. Ant has fallen out of favour for builds, with most devs now using either Maven or Gradle. Read up on / play around with both of those and you'll be in good shape there.

Also, Java shops have also been affected by the overall move to "The Cloud" and you can't really ignore that either. If you haven't already, you'll probably want to familiarize yourself with AWS and the AWS SDK.

If you want to work/play in the "big data" space, you'll need some combination of Hadoop, Kafka, Spark, Hive, Storm, Flume, HBase, Impala, etc., etc., etc.

jozi9
Wow, reading through all of that (and how you put it in perspective) felt like I'm waking up from Hibernation (pun intended). Solid advices, thanks a lot!
PaulHoule
I think maven in the ecosystem around it is the biggest thing.

maven makes it easy to incorporate 100s of Jars into your projects, but then you get to discover the conflicts between 100s of Jars, create build processes that don't finish before your project is due, etc.

Master maven and then modern Java may seem like a lot of fun!

You could probably read this decade old book:

http://www.amazon.com/Java-Concurrency-Practice-Brian-Goetz/...

and it'd be a good start. It's in "boring" old Java, but it goes over a lot of the meat and potatoes concepts.

fapjacks
I can recommend this book as well. I don't write a lot of Java, but this is great for the general topic.
I have probebly not done much Java Concurrency. Sure you can simulate CSP with Blocking Queues but since you bind real threads you will run into tons of problems.

Why dont we ask Brian Goetz a Java Language Architect how "easy" it is, read his book [1] and then lets talk again how easy it is.

[1] http://www.amazon.com/Java-Concurrency-Practice-Brian-Goetz/...

Apr 05, 2014 · adem on DIY Computer Science Degree
I think this list is missing some important parts of computer science.

Here are the books that our university uses for first-year students combined with books that I found to be useful:

Introduction to Programming (using Eiffel) [1]

Mathematics for Computer Science (or: Discrete Mathematics) [2]

Introduction to Datastructures and Algorithms [3]

Introduction to Digital Design [4]

Parallel Programming (using Java) [5]

Optional but highly recommended, you'll probably find it completely out of scope:

Real Analysis I [6]

Real Analysis II [7]

Introduction to Linear Algebra [8]

Introduction to Physics [9]

[1]: http://www.amazon.com/Touch-Class-Learning-Program-Contracts...

[2]: http://ocw.mit.edu/courses/electrical-engineering-and-comput...

[3]: http://www.amazon.de/Introduction-Algorithms-Thomas-H-Cormen...

[4]: http://www.amazon.com/Digital-Design-Computer-Architecture-E...

[5]: http://www.amazon.com/Java-Concurrency-Practice-Brian-Goetz/...

[6]: http://www.amazon.com/Analysis-Texts-Readings-Mathematics-No...

[7]: http://www.amazon.com/Analysis-II-Texts-Readings-Mathematics...

[8]: http://www.amazon.com/Introduction-Linear-Algebra-Fourth-Gil...

[9]: http://www.amazon.com/Fundamentals-Physics-Extended-David-Ha...

iamryandrake
Thanks so much for this list! What's your Twitter handle I can follow you on?

Have added this list to my project!

adem
Unfortunately I don't use Twitter anymore. Good luck with your journey!
If this is interesting to you then I'd highly recommend Java Concurrency in Practice [1]. It goes through the then-new java.util.concurrent package, but more importantly, does a really good job of making all of the theoretical concepts straightforward to grasp

1 - http://www.amazon.com/gp/aw/d/0321349601

bruceboughton
I've been searching for a book like this for .NET and the CLR to no avail. Can anyone recommend one?

Or is this book applicable beyond Java?

cokernel_hacker
Concurrent Programming on Windows by Joe Duffy http://www.amazon.com/exec/obidos/ASIN/032143482X/bluebyteso...
bruceboughton
Thanks. I will take a look.
jedimouse
Great book indeed. Along with effective Java, its one of my alltime favorites. But since its a Java book, it doesnt if I recall correctly detail how things are implemented at the core JVM level. Does anyone know a good book or source about that?
gtani
this was good http://www.artima.com/insidejvm/ed2/threadsynch3.html
kasey_junk
It depends on the JVM you are using. If it is an open source one you can look yourself.

A little old but Oracle JRockit: The Definitive Guide is a pretty good book on the JRockit JVM.

I found Java Concurrency in Practice to be a pretty solid read.

http://www.amazon.com/Java-Concurrency-Practice-Brian-Goetz/...

GeoKeaton
Cheers I'll give that one a look
#1. "Java Concurrency in Practice" http://www.amazon.com/Java-Concurrency-Practice-Brian-Goetz/...

#2. ... hmm, that might be it.

Mar 05, 2010 · locopati on [Missing Story]
For those doing Java coding, this is _the_ book to have http://www.amazon.com/Java-Concurrency-Practice-Brian-Goetz/...

You never know when that library designed without threads in mind will end up in a threaded environment (which one could argue is part of the problem with leaving concurrency up to the coder in the way that Java does, versus building it into the language the way Erlang does).

Jun 20, 2009 · icey on Books that influenced Clojure
I'm shocked that Java Concurrency in Practice isn't in the list:

http://www.amazon.com/Java-Concurrency-Practice-Brian-Goetz/...

I only know about that book because of Rich's mentions of it.

To be honest, I"m also a little surprised that the Pickaxe book is in the list. Not that Ruby isn't the bees knees; it just didn't strike me as being influential on Clojure.

charrington
I, too, am surprised that Java Concurrency in Practice is missing. Rich has mentioned several times. Odd.

As for the Ruby influence, Rich mentioned that he is a "language nerd" and learns all kinds of languages. Whether any one language shows up in some way in Clojure is another matter ;-) I think the Ruby influence shows up in Clojure's ease of scripting Java, cutting through the ceremony to get things done in minimal code.

richhickey
I'm sure I selected it, but I didn't realize it hadn't gone into the list. Now fixed - thanks.
HN Books is an independent project and is not operated by Y Combinator or Amazon.com.
~ yaj@
;laksdfhjdhksalkfj more things
yahnd.com ~ Privacy Policy ~
Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.