O'Reilly logo
live online training icon Live Online training

Java concurrency

Understanding concurrent programming in Java

Topic: Software Development
Ben Evans

A thorough understanding of concurrency is what will really set you apart as a Java developer. Expert Ben Evans provides you with a foundation to become truly confident and proficient with concurrent programming in Java. You’ll explore both the “classic” concurrency API based on synchronization and more modern “lock-free” approaches that rely on modern hardware.

What you'll learn-and how you can apply it

By the end of this live online course, you’ll understand: - Java’s original concurrency model based on synchronization - Why advances in hardware mean you can do better work on modern CPUs - How the modern java.util.concurrent libraries work

And you’ll be able to: - Build your own concurrent applications - Decide when each technique is appropriate for your application - Safely migrate legacy synchronized code to modern approaches

This training course is for you because...

This course is for you because… - You’re a Java developer who wants to level up. - You work with concurrent or distributed systems. - You want to become an architect or senior developer.


Prerequisites: - A working knowledge of Java - A basic understanding of concurrency in other languages (useful but not required) - Familiarity with CPU architecture (useful but not required)

Recommended preparation: - A laptop with a Java environment and an IDE of your choice installed (Java 11 is recommended for the best experience, as you’ll reference some post-8 APIs, and some simple exercises will use the JShell REPL (which is not available in Java 8).)

Recommended follow-up: - Read “Java’s Support for Concurrency” (chapter 6 in Java in a Nutshell, seventh edition) - Read “Concurrent Performance Techniques” (chapter 12 in Optimizing Java)

About your instructor

  • Ben Evans is principal engineer and architect for JVM technologies at New Relic. Previously, Ben was a cofounder of the Java performance startup jClarity (acquired by Microsoft), chief architect for listed derivatives at Deutsche Bank, and senior developer at Morgan Stanley, where he was responsible for performance testing the systems used for Google’s IPO. He’s the author of Optimizing Java, the recently updated Java in a Nutshell, seventh edition, The Well-Grounded Java Developer, and Java: The Legend. He’s the Java and JVM track lead at InfoQ, a frequent contributor to Oracle's Java Magazine, and a regular speaker at conferences worldwide. Ben has been contributing to open source software for over 20 years. He was a cofounder of the Adopt-a-JSR and AdoptOpenJDK initiatives and served on the Java Community Process Executive Committee for six years.


The timeframes are only estimates and may vary according to how the class is progressing

Synchronization (55 minutes) - Lecture: The simple hardware model; the need for synchronization; the original Thread and Synchronization API - Hands-on exercises: Identify the effect of hardware caching; see the relative speed of synchronized versus unsynchronized access - Q&A

Break (5 minutes)

Introducing the java.util.concurrent libraries (55 minutes) - Lecture: Concurrent data structures; locks in java.util.concurrent; atomics, latches, and barriers - Hands-on exercise: Get to know ConcurrentHashMap; rewrite a synchronization-based system - Q&A

Break (5 minutes)

Under the hood of java.util.concurrent (55 minutes)

  • Lecture: Inside AtomicInteger; LinkedBlockingQueue
  • Hands-on exercise: Explore the relative speed of atomic and CAS access; build your own atomic
  • Q&A

Break (5 minutes)

Practical considerations (50 minutes) - Lecture: Amdahl’s law and Little’s law; how to size thread pools - Group discussion: Queuing theory - Hands-on exercise: Discover if parallel streams are worth it

Wrap-up and Q&A (10 minutes)