O'Reilly logo
live online training icon Live Online training

Java Concurrency

Understanding concurrent programming in Java

Ben Evans

This session provides a deep dive into how Java’s concurrency actually works. It covers both the “classic” concurrency API based on synchronization and the more modern “lock-free” approaches that rely on modern hardware.

A thorough understanding of concurrency really sets a good Java developer apart from their peers, and this session aims to provide a foundation for developers to become truly confident and proficient with concurrent programming in Java.

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

By the end of this live, hands-on, online course, you’ll understand:

  • Java’s original concurrency model – based on synchronization
  • Why advances in hardware mean we can do better on modern CPUs
  • How the more modern java.util.concurrent libraries work

And you’ll be able to:

  • Start building 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...

  • You’re a mid-to-advanced Java dev who wants to level up
  • You work with concurrent or distributed systems
  • You want to become an architect or senior developer


  • Medium to advanced knowledge of Java programming
  • Any knowledge of concurrency in other languages will be very helpful
  • Basic working knowledge of CPU architecture will be very useful

Recommended preparation:

  • This course is intended for experienced Java developers, so we expect you to already have a Java environment and IDE installed.
  • We recommend Java 11 for the best experience, as the course will reference some post-8 APIs (although not in detail), and some simple exercises will use the JShell REPL (which is not available in Java 8).

Recommended follow-up:

About your instructor

  • Ben Evans is Principal Engineer and Architect for JVM technologies at New Relic. Prior to joining New Relic, Ben co-founded the Java performance startup jClarity (acquired by Microsoft) and was Chief Architect for Listed Derivatives at Deutsche Bank. He was a Senior Developer at Morgan Stanley, where he was responsible for performance testing the systems used for Google’s IPO.

    Ben is the author of Optimizing Java, the recently-updated Java in a Nutshell, 7th Edition, The Well-Grounded Java Developer, and Java: The Legend. He is the Java / 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 co-founded the Adopt-a-JSR and AdoptOpenJDK initiatives, and served on the Java Community Process Executive Committee for 6 years.


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

Synchronization (55 minutes)

  • Presentation: Simple Hardware Model (15 mins)
  • Exercise: Effect of Hardware Caching (5 mins)
  • Presentation: The Need for Synchronization (10 mins)
  • Exercise: Relative speed of synchronized vs unsynchronized access (5 minutes)
  • Presentation: The Original Thread & Synchronization API (15 mins)
  • Q&A (5 mins)
  • Break (5 minutes)

Introducing the java.util.concurrent libraries (55 minutes)

  • Presentation: Concurrent Data Structures (15 mins)
  • Exercise: Getting to Know ConcurrentHashMap (5 mins)
  • Presentation: Locks in java.util.concurrent (10 mins)
  • Exercise: Rewriting a synchronization-based system (10 mins)
  • Presentation: Atomics, Latches and Barriers (10 mins)
  • Q&A (5 mins)
  • Break (5 minutes)

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

  • Presentation: Inside AtomicInteger (20 mins)
  • Exercise: Relative speed of atomic / CAS access (5 mins)
  • Presentation: Building up LinkedBlockingQueue (15 mins)
  • Exercise: Build your own Atomic (10 mins)
  • Q&A (5 mins)
  • Break (5 minutes)

Practical Considerations (60 minutes)

  • Presentation: Amdahl’s Law and Little’s Law (15 mins)
  • Discussion: Queuing Theory (10 mins)
  • Presentation: Thread pools and how to size them (10 mins)
  • Exercise: Are Parallel Streams worth it? (15 mins)
  • Q&A (10 mins)