本课程紧跟JDK 27标准,通过250多个真实并发Bug案例,深入讲解Java多线程与并发编程,涵盖虚拟线程、结构化并发及死锁排查等高级面试要点,助你升级现代Java并发架构思维。

原始标题:Java Multithreading & Concurrency: Virtual Threads, Java 27

Java Multithreading & Concurrency: Virtual Threads, Java 27

本课程是一门彻底紧跟 JDK 27 最新标准 的 Java 高并发与多线程深度实战硬核教程。课程完全围绕真实且诡异的并发 Bug 展开,比如在没有抛出任何错误的情况下 10 个线程把计数器加到了 13 万而不是 100 万,或者程序莫名其妙死锁挂起却能通过常规测试。讲师拒绝使用任何繁琐的 IDE 或构建工具,坚持让学员使用最纯粹的命令行和文本编辑器,在对 250 多个精简多线程程序的“结果预测与翻车运行”中,通过生动的火车站售票员动画模型,将原本抽象的底层并发原理彻底讲透,是准备 Java 高级面试(如死锁排查、wait 为什么要放在 while 循环里等经典问题)的绝佳复习材料。

在技术栈上,本课最大的亮点在于其跨时代的演进对比与前沿探索。它不仅带你重温底层的 synchronized 和 ReentrantLock,更详细拆解了自 Java 21 引入、在 Java 25 和 Java 27 逐步走向成熟与最终定型的现代并发技术。你将亲手体验瞬间启动 100 万个虚拟线程的震撼,利用最新的结构化并发(StructuredTaskScope) 框架在单一截止时间内规范管理子任务的成败,并通过真实的数据实测,见证由于 JDK 内核优化,一个在 Java 21 下会严重卡顿虚拟线程的锁操作在 Java 27 下如何被优化得流畅无比。这对于那些停留在旧版本、急需升级现代 Java 并发架构思维的资深开发人员和自学者来说,是一门含金量极高的必修课。

  1. 从单线程到多线程(基础篇):彻底分清 Thread 与 Runnable,理清 start() 与 run() 的本质区别,掌握如何通过 sleep、join 和 interrupt 优雅控制线程。
  2. 多线程共享带来的灾难(线程安全篇):用反例展示 10 个线程同时对一个计数器累加 100 万次却漏掉大半更新的经典竞态条件(Race Condition)。学习用 synchronized 和锁修复它;利用 wait 和 notifyAll 编写生产者-消费者模型;学看 jstack 线程堆栈分析死锁,并通过调整加锁顺序消除死锁。
  3. Java 官方并发工具箱(进阶篇):熟练运用 ExecutorService 线程池、用 Callable 和 Future 获取异步返回值,以及使用 ConcurrentHashMap、AtomicInteger、LongAdder 和 Semaphore 替代传统不安全或低效的工具。
  4. 现代 Java 颠覆性新特性(高阶篇):在 JDK 27 中一键启动 100 万个虚拟线程。深入理解载体线程(Carrier Threads)与线程钉死(Pinning)现象。使用 结构化并发(StructuredTaskScope) 让一组子任务同生共死,以及用 ScopedValue 替代老旧的 ThreadLocal 安全共享数据。

Published 10/2026
Created by Anand Rochlani MTS At Salesforce
MP4 | Video: h264, 1920×1080 | Audio: AAC, 44.1 KHz, 2 Ch
Level: Intermediate | Genre: eLearning | Language: English | Duration: 54 Lectures ( 10h 10m ) | Size: 9.6 GB

Java concurrency from the first thread to structured concurrency: race conditions, deadlock, thread pools, 250+ programs

What you’ll learn
⚡ Explain why ten threads lose most of a million updates to one shared counter with no error, show the race condition with javap, and fix it with synchronized
⚡ Read a jstack thread dump of a hung program: which thread holds which lock, and on which line. Then make the deadlock impossible with one lock order
⚡ Run tasks on an ExecutorService thread pool: choose fixed or cached, size it for work that waits or computes, and shut it down so the JVM exits
⚡ Start a million virtual threads, explain carrier threads and pinning, and limit calls to a slow service with a Semaphore instead of a pool
⚡ Use structured concurrency: group subtasks in a StructuredTaskScope so they succeed or fail together under one deadline, and share a value with ScopedValue
⚡ Create threads with Thread and Runnable, explain start versus run, wait for threads to finish with join, and ask a thread to stop with interrupt
⚡ Write a producer and a consumer with wait and notifyAll, and explain why wait belongs in a while loop inside synchronized
⚡ Return results with Callable and Future: put a timeout on get, cancel a task, read the real failure with getCause, and use invokeAll or invokeAny
⚡ Replace a HashMap that loses entries under threads with ConcurrentHashMap, close a get-then-put gap with merge, and count with AtomicInteger or LongAdder
⚡ Say what volatile guarantees and what it does not, and use ReentrantLock with tryLock and a timeout so that a thread gives up instead of hanging
⚡ Explain why a synchronized block that held up virtual threads on Java 21 no longer does on Java 27, using one file measured on Java 21, 25 and 27

Requirements
❗ Java basics: classes and objects, methods, interfaces, exceptions with try and catch, and generic types such as a List of String
❗ No threading knowledge is needed. Lambdas, records and try-with-resources are explained when they first appear
❗ JDK 27: the first line of java -version must say 27. JDK 21 refuses most of the programs as written. Structured concurrency programs need –enable-preview
❗ No IDE and no build tool. Each program is one source file that you run in a terminal with java and the file name. Any text editor works
❗ A few gigabytes of free memory. Several lectures start a million threads, and the heaviest run peaked at about 2.4 GB on the instructor’s 16 GB Mac

Description
This course contains the use of artificial intelligence.

Ten threads each add one to a shared counter 100,000 times, the program prints 136,405 instead of 1,000,000, and nothing reports an error. This Java multithreading course explains that result and others like it, from your first thread to virtual threads and structured concurrency on Java 27, with more than 250 small programs to try yourself.

A bug in threaded code often looks like that one: every line ran as written, and the answer is wrong. Another program in the course contains a deadlock and still passed 200 runs in a row, so tests alone do not find these bugs. If you can start a thread but cannot say why that total is wrong, or you watched thread tutorials and remembered little, this Java concurrency course was written for you.

The route, in four steps
✨One thread becomes several. Start threads with Thread and Runnable, explain start versus run, and control them with sleep, join and interrupt.

✨What goes wrong when threads share. Fix a race condition with synchronized, coordinate threads with wait and notifyAll, read a deadlock in a jstack thread dump, and prevent it with one lock order.

✨Java’s own tools. Run work on ExecutorService thread pools, collect results with Callable and Future, and share data with ConcurrentHashMap, AtomicInteger and BlockingQueue.

✨Modern Java. Start a million virtual threads, then group tasks in a StructuredTaskScope so that they succeed or fail together, and share a value with ScopedValue.

How each lecture works
After the short Start Here section, each lecture opens on a real run, often a wrong total, a hang, or a program that exits before its work is done. Before a program runs, you predict the result while a small clock ticks. A wrong guess shows which picture in your head needs fixing. The video is narrated animation, not slides read aloud: code, terminal output and one drawn story, a railway station where every clerk behind a booking window is a thread. Most lectures run ten to twelve minutes.

Is Java 27 too new for your job?
Every program was run on Java 27 and every result was measured for this course, so you need JDK 27 to run the code as written. No IDE or build tool is needed: you start each file with java and the file name. Most of what you learn is far older: Runnable dates from Java 1.0 and Callable from Java 5. Virtual threads have been standard since Java 21, and scoped values are final since Java 25. Structured concurrency is still a preview API in Java 27, so the programs that use it run with the –enable-preview flag and may need edits at the next release. Where advice changed between versions, the course measures it: a thousand virtual threads, each holding a synchronized lock while it sleeps, took 10,364 milliseconds on Java 21 and 112 on Java 27.

What this course does not cover
CompletableFuture is named once and not taught. The course also leaves out CountDownLatch, CyclicBarrier, ReadWriteLock, scheduled executors and the fork/join framework. There are no reactive frameworks, no parallel streams and no Spring, and nothing runs across several machines. You need Java basics, but no threading knowledge.

Check it before you decide
Judge this course by what you can verify. The code is in a public GitHub repository, AnandRochlani/java-multithreading, with the output captured on the instructor’s machine. Watch the free preview lectures, predict each run, then run one program and compare your output. Then decide for yourself.

Who this course is for
⭐ Java developers who can start a thread but cannot yet say why a shared total comes out wrong, or why a program hangs with no error
⭐ Developers on Java 17 or 21 who hear about virtual threads and structured concurrency and want to see them run and measured on a current JDK
⭐ Developers who watched thread tutorials before and remembered little: here you predict what a program will do before it runs
⭐ Developers preparing for interview questions such as start versus run, sleep versus wait, deadlock, and producer and consumer
⭐ Students and self-taught programmers who know Java basics and have never written a thread: the course begins before the first one
⭐ Not for you if you are new to Java, or need CompletableFuture, CountDownLatch, the fork/join framework, parallel streams, reactive frameworks or Spring

隐藏内容

此处内容需要权限查看

  • 普通3金币
  • 会员免费
  • 永久会员免费推荐
会员免费查看

发表回复

您的邮箱地址不会被公开。 必填项已用 * 标注