Menu
The Definitive Guide to Java Platform Best Practices–Updated for Java 7, 8, and 9
Other Articles You May Like to Explore
The Complete Java MasterClass
10 Testing Tools Java Developers Should Know
5 Frameworks Java Developers Should Learn in 2019
Finally, Java has var to declare Local Variables
10 Things Java and Web Developer Should Learn in 2019
10 Books Every Java Programmer Should Read in 2019
10 Tools Java Developers uses in their day-to-day work
Top 5 Courses to learn Java Multithreading in depth
Applying Concurrency and Multi-threading to Common Java Patterns
Thanks for reading this article so far. If you also love to see a new and updated version of Java Concurrency in Practice then please share this article on Facebook and Twitter and maybe our request will reach to Brian and the publisher of the book.
P.S. - Let's hope Brian Goetz and other authors of the book listen to this request and gift Java developers around the world with a new version of Java Concurrency in Practice in 2019 until then Dr. Heinz Kabutz' Java Concurrency in Practice Bundle can be used to keep yourself up-to-date.
Java documentation, at least at the time of writing, is not great when it comes to documenting thread safety guarantees. Latches, barriers, semaphores, and blocking queues are types of synchronizers. Latches block all threads until the terminal state is reached in which case all threads unblock.
Java has changed dramatically since the previous edition of Effective Java was published shortly after the release of Java 6. This Jolt award-winning classic has now been thoroughly updated to take full advantage of the latest language and library features. The support in modern Java for multiple paradigms increases the need for specific best-practices advice, and this book delivers.
As in previous editions, each chapter of Effective Java, Third Edition, consists of several “items,” each presented in the form of a short, stand-alone essay that provides specific advice, insight into Java platform subtleties, and updated code examples. The comprehensive descriptions and explanations for each item illuminate what to do, what not to do, and why.
The third edition covers language and library features added in Java 7, 8, and 9, including the functional programming constructs that were added to its object-oriented roots. Many new items have been added, including a chapter devoted to lambdas and streams.
New coverage includes
- Functional interfaces, lambda expressions, method references, and streams
- Default and static methods in interfaces
- Type inference, including the diamond operator for generic types
- The @SafeVarargs annotation
- The try-with-resources statement
- New library features such as the Optional interface, java.time, and the convenience factory methods for collections
One of my reader Shobhit asked this question on my blog post about 12 must-reads advanced Java books for intermediate programmers - part1. I really like the question and thought that many Java programmers might have the same doubt whenever someone recommends them to read Java Concurrency in Practice. When this book came first in 2006, Java world was still not sure of about new concurrency changes made in Java 1.5, I think the first big attempt to improve Java's built-in support for multi-threading and concurrency. Many Java programmers were even not aware of new tools introduced in the API e.g. CountDownLatch, CyclicBarrier, ConcurrentHashMap and much more. The book offered them the seamless introduction of those tools and how they can use them to write high-performance concurrent Java applications.
This is the general view of the book, which many Java developer will give you when you asked them about how did you find 'Java Concurrency in Practice', but mine view is slightly different from them and that's the main reason I still recommend Java Concurrency in Practice to any new Java developer or intermediate developers who want to master concurrency concepts.
The most important thing this book introduce was clear concepts and fundamentals of concurrent programming e.g. visibility, ordering, thread-safety, immutability, parallelism etc.
It also goes on to explain why most concurrent applications are incorrectly written in Java and the common mistakes made by Java programmers which result in multi-threading issues like race conditions, deadlock, livelock, memory interference, and simply incorrect calculation.
Emoticons are used to show the bad practice before introducing the good and right way to do helped a lot not only to correct the misconception many Java developer had before but to sow the seed of right information pertaining to multi-threading and concurrency among Java developers.
No doubt that multi-threading and concurrency are difficult, they are both hard to get it right in code and hard to understand and explain. I have seen many programmers who simply wasn't able to visualize how multiple threads are interacting with the same piece of code with different data.
Much like the classical concept of recursion which is too easy for some programmers but too difficult for others to grasp and apply in the real-world scenario.
The biggest contribution of the Java Concurrency in Practice to the Java world is not making concurrency easy but providing the correct and clear information which was lacking. Since I have taken a lot of interviews, I know that programmers always have misconceptions about threads and how they work.
Many programmers even with 4 to 5 years of experience in Java didn't understand how volatile variable works, what they know is that when you use a volatile variable it always check the value from main memory while comparing, which is the truth but not complete.
They were not told about the Java memory model and how volatile variable can affect the ordering of code and computing instructions behind code by JIT and JVM for optimization which could result in subtle logical bugs.
They were not made aware of how volatile can guarantee visibility of what was done by one thread prior to accessing volatile variable to other thread etc. They don't know what is a memory barrier and how does it impact visibility.
The Java Concurrency in Practice book teach those concepts to many Java programmer. In fact, I would admit that before reading that book, I have lots of misconceptions about many essential multi-threading and concurrency concepts e.g. ordering, visibility and subtle effect of final variables and safe-publication, the book helped me to clear those.
Btw, if you find some sections of the book difficult to understand then you are not alone, but thankfully Dr. Heinz Kabutz's has simplified them in his Java Concurrency in Practice Bundle course.
If you think even that is tough then Mastering Threads is another course by Heinz, which simplifies the multithreading for average Java programmer. He is also offering a 30% discount until the 19th of February.
Now, coming back to Java 8, yes from Java 1.5 to Java 8, JDK has a lot more new tools to implement concurrency and design better Java concurrent application. The introduction of fork-join pool in JDK 7, CompleteableFutures in Java 8 and most importantly the new functional style of coding in Java 8 supported by the lambda expression.
You also got the stream and parallel stream which allows developers to take advantage of concurrency without coding it. The overall idea of moving concurrency from application developer to API developers also makes it a little easier and reduced risk of implementing concurrency in Java.
It also means that now you can perform the bulk operation in Java with just a couple of methods and multiple threads without writing a single line of code involving threads, synchronized keyword, or wait-notify methods.
No doubt, that Java developer has to learn these new tools to keep themselves up-to-date and a book like Java 8 in Action really helps on that front. It introduces you to all new changes in Java 8 and not only teaches you how to use them in your day-to-day task but also explains the motivation behind them to understand the bigger picture.
Even though Java Concurrency in Practice in its current state doesn't cover all these important concepts and tools, it's still an invaluable book to learn the fundamentals of threads, concurrency and multi-threading tools supported by Java programming language.
It's still a must-read book for any Java developer who wants to learn and master multi-threading and concurrency, the biggest advantage of using Java for application development.
Java developers are thankful to Brian Goetz, Joshua Bloch and all the authors for giving Java developer such authority book to understand the confusing but critical concepts of multi-threading and concurrency.
Having said that, like many Java developers around the world, I would also love to see a newer, more up-to-date version of Java Concurrency in Practice to cover tools and methodologies introduced in Java 6, 7, 8, 9, 10, 11, 12 and maybe in Java 13 in coming months, much like the updated version of Effective Java and Head First design pattern which covers Java 8 and teaches you how certain patterns are easier to implement with new Java 8 features.
This is the general view of the book, which many Java developer will give you when you asked them about how did you find 'Java Concurrency in Practice', but mine view is slightly different from them and that's the main reason I still recommend Java Concurrency in Practice to any new Java developer or intermediate developers who want to master concurrency concepts.
The most important thing this book introduce was clear concepts and fundamentals of concurrent programming e.g. visibility, ordering, thread-safety, immutability, parallelism etc.
It also goes on to explain why most concurrent applications are incorrectly written in Java and the common mistakes made by Java programmers which result in multi-threading issues like race conditions, deadlock, livelock, memory interference, and simply incorrect calculation.
Emoticons are used to show the bad practice before introducing the good and right way to do helped a lot not only to correct the misconception many Java developer had before but to sow the seed of right information pertaining to multi-threading and concurrency among Java developers.
No doubt that multi-threading and concurrency are difficult, they are both hard to get it right in code and hard to understand and explain. I have seen many programmers who simply wasn't able to visualize how multiple threads are interacting with the same piece of code with different data.
Much like the classical concept of recursion which is too easy for some programmers but too difficult for others to grasp and apply in the real-world scenario.
The biggest contribution of the Java Concurrency in Practice to the Java world is not making concurrency easy but providing the correct and clear information which was lacking. Since I have taken a lot of interviews, I know that programmers always have misconceptions about threads and how they work.
Many programmers even with 4 to 5 years of experience in Java didn't understand how volatile variable works, what they know is that when you use a volatile variable it always check the value from main memory while comparing, which is the truth but not complete.
They were not told about the Java memory model and how volatile variable can affect the ordering of code and computing instructions behind code by JIT and JVM for optimization which could result in subtle logical bugs.
They were not made aware of how volatile can guarantee visibility of what was done by one thread prior to accessing volatile variable to other thread etc. They don't know what is a memory barrier and how does it impact visibility.
The Java Concurrency in Practice book teach those concepts to many Java programmer. In fact, I would admit that before reading that book, I have lots of misconceptions about many essential multi-threading and concurrency concepts e.g. ordering, visibility and subtle effect of final variables and safe-publication, the book helped me to clear those.
Btw, if you find some sections of the book difficult to understand then you are not alone, but thankfully Dr. Heinz Kabutz's has simplified them in his Java Concurrency in Practice Bundle course.
If you think even that is tough then Mastering Threads is another course by Heinz, which simplifies the multithreading for average Java programmer. He is also offering a 30% discount until the 19th of February.
Now, coming back to Java 8, yes from Java 1.5 to Java 8, JDK has a lot more new tools to implement concurrency and design better Java concurrent application. The introduction of fork-join pool in JDK 7, CompleteableFutures in Java 8 and most importantly the new functional style of coding in Java 8 supported by the lambda expression.
You also got the stream and parallel stream which allows developers to take advantage of concurrency without coding it. The overall idea of moving concurrency from application developer to API developers also makes it a little easier and reduced risk of implementing concurrency in Java.
It also means that now you can perform the bulk operation in Java with just a couple of methods and multiple threads without writing a single line of code involving threads, synchronized keyword, or wait-notify methods.
No doubt, that Java developer has to learn these new tools to keep themselves up-to-date and a book like Java 8 in Action really helps on that front. It introduces you to all new changes in Java 8 and not only teaches you how to use them in your day-to-day task but also explains the motivation behind them to understand the bigger picture.
Even though Java Concurrency in Practice in its current state doesn't cover all these important concepts and tools, it's still an invaluable book to learn the fundamentals of threads, concurrency and multi-threading tools supported by Java programming language.
It's still a must-read book for any Java developer who wants to learn and master multi-threading and concurrency, the biggest advantage of using Java for application development.
Java developers are thankful to Brian Goetz, Joshua Bloch and all the authors for giving Java developer such authority book to understand the confusing but critical concepts of multi-threading and concurrency.
Having said that, like many Java developers around the world, I would also love to see a newer, more up-to-date version of Java Concurrency in Practice to cover tools and methodologies introduced in Java 6, 7, 8, 9, 10, 11, 12 and maybe in Java 13 in coming months, much like the updated version of Effective Java and Head First design pattern which covers Java 8 and teaches you how certain patterns are easier to implement with new Java 8 features.
Other Articles You May Like to Explore
The Complete Java MasterClass
10 Testing Tools Java Developers Should Know
5 Frameworks Java Developers Should Learn in 2019
Finally, Java has var to declare Local Variables
10 Things Java and Web Developer Should Learn in 2019
10 Books Every Java Programmer Should Read in 2019
10 Tools Java Developers uses in their day-to-day work
Top 5 Courses to learn Java Multithreading in depth
Applying Concurrency and Multi-threading to Common Java Patterns
Thanks for reading this article so far. If you also love to see a new and updated version of Java Concurrency in Practice then please share this article on Facebook and Twitter and maybe our request will reach to Brian and the publisher of the book.
P.S. - Let's hope Brian Goetz and other authors of the book listen to this request and gift Java developers around the world with a new version of Java Concurrency in Practice in 2019 until then Dr. Heinz Kabutz' Java Concurrency in Practice Bundle can be used to keep yourself up-to-date.