Udemy
    •  
    •  
    •  
    •  
    •  
    •  
    •  
    •  
Turn what you know into an opportunity and reach millions around the world.
Learn More
Your cart is empty.
Keep shopping
Java Concurrency Mastery: Threads, Pools, Virtual Threads
Rating: 5.0 out of 5(9 ratings)
322 students

Java Concurrency Mastery: Threads, Pools, Virtual Threads

From race conditions to virtual threads: write correct, fast, scalable concurrent Java with hands-on examples
Last updated 7/2026
English

What you'll learn

  • Create and coordinate threads and fix real race conditions with synchronized, volatile, and atomic variables
  • Use the java.util.concurrent toolkit: ReentrantLock, conditions, CountDownLatch, Semaphore, and CyclicBarrier
  • Replace hand-managed threads with ExecutorService, Callable, Future, and correctly sized thread pools
  • Compose asynchronous work with CompletableFuture, including chaining, fan-out, fan-in, and error handling
  • Apply the modern toolkit: ConcurrentHashMap, BlockingQueue, parallel streams, fork/join, and virtual threads
  • Understand the Java Memory Model and the happens-before rule that governs visibility and ordering
  • Diagnose and prevent deadlock, livelock, starvation, false sharing, and other concurrency failure modes
  • Choose the right concurrency tool for the job and write code that scales on modern multicore hardware

Course content

5 sections36 lectures3h 22m total length
  • The End of the Free Lunch: Why Concurrency Went Mainstream5:46

    A timeline-driven story of how single-core clock speeds stalled in the mid-2000s as Dennard scaling broke down, ending the era when programs got faster for free with each new chip. You'll see how the industry pivoted to multicore, and why that hardware shift forced ordinary developers to learn concurrency to use the cores they were now paying for. This frames the whole course as learning to spend those cores safely.

  • Creating Threads: Thread, Runnable, and Lambdas6:33

    You'll write and run threads three ways: subclassing Thread, implementing Runnable, and passing a lambda — built around a busy restaurant kitchen with a saute cook, a prep cook, and a garnish one-liner. You'll see start() versus calling run() directly, and use join() to wait for a thread to finish. Thread names printed in the output let you watch real interleaving as several threads run side by side.

  • The Race Condition, Caught in the Act7:36

    You'll build a runnable example where many threads increment a shared XP counter without coordination, then run it to watch the final total come out wrong and different every run. The bug is made concrete and reproducible — including a "boss fight" where hits never land — so the rest of the section has a real problem to solve, and you'll watch the same code produce a different answer every single time.

  • synchronized: The Lock You Already Have6:43

    You'll fix the broken counter with synchronized methods and synchronized blocks, learning about intrinsic locks and the object monitor every Java object carries. Running the corrected version — a goblin gold glitch and a guild treasury heist — gives you a now-consistent total. You'll also weigh the trade-off: correctness at the cost of serialized, one-lane access.

  • volatile and the Visibility Problem7:20

    You'll watch a thread that never sees another thread's update to a boolean stop flag — a rover that will not halt — then fix it with volatile to guarantee visibility. You'll see clearly that volatile solves visibility but not atomicity: a volatile count++ is still a race. Both the broken and fixed versions run so you can compare them.

Requirements

  • Solid working knowledge of core Java: classes, methods, generics, and collections
  • Comfort writing, compiling, and running Java programs (JDK installed)
  • Familiarity with using a terminal or command line and an IDE
  • A computer running Windows, macOS, or Linux with JDK 17 or newer
  • No prior experience with threads or concurrency required

Description

This course contains the use of artificial intelligence.

Java concurrency is the skill that separates developers who can use modern multicore hardware from those who quietly leave most of their CPU idle. This course teaches it the way it actually clicks: by weaving short conceptual lectures together with hands-on code you can run yourself. Each coding section opens with a single plain-English concept lecture that frames the problem, and then every idea after it is something you build, run, and watch behave on real threads.

You will start at the metal: creating threads, watching a shared counter corrupt itself in a live race condition, and then fixing it with synchronized, volatile, and atomic variables. From there you move up the stack to the java.util.concurrent toolkit — explicit locks, condition variables, latches, semaphores, and barriers — and then to executors and thread pools, where you stop hand-managing threads and start submitting tasks. The async chapters take you through CompletableFuture composition (chaining, fan-out, fan-in, and error handling), and the final stretch covers the modern toolkit: concurrent collections, the producer-consumer pattern, parallel streams, fork/join, and virtual threads from Project Loom.

The course is structured as five sections, each anchored by runnable examples so the theory always has somewhere to land. Concepts and code are interleaved deliberately: you meet a hazard, you see it bite, and then you neutralize it with the right tool. Code lectures use vivid, memorable examples — RPG raids, busy kitchens, detective evidence rooms, and more — to keep the mechanics concrete while the underlying Java APIs stay exactly what you would use in production.

The closing lectures pull everything together at a conceptual level. The final section ends with a run of deeper conceptual lectures that every serious concurrent programmer needs: a map of the full concurrency toolbox, the happens-before rule that makes reasoning about visibility possible, the classic failure modes (deadlock, livelock, and starvation), false sharing and mechanical sympathy, a practical playbook for debugging Heisenbugs, and a look at where Java concurrency is heading with virtual threads, structured concurrency, and scoped values. You finish able to write concurrent Java that is correct, fast, and genuinely understandable.

Who this course is for:

  • Java developers who want to write correct, fast, and scalable concurrent code
  • Backend engineers building multithreaded services and high-throughput systems
  • Developers preparing for interviews on threads, the memory model, and executors
  • Engineers modernizing toward CompletableFuture, parallel streams, and virtual threads
  • Self-taught Java programmers who want to stop fearing race conditions and deadlocks