Virtual Threads 是 JDK 21 正式推出的輕量執行緒,讓 JVM 在少數 OS thread 上多工跑大量虛擬執行緒,不用再靠加大 thread pool 來撐高並發 IO。這篇從 Platform Thread 的瓶頸講起,整理 carrier thread 的 mount / unmount 機制、API 用法、pinning 問題與 JDK 24 的改善,附 Spring Boot 整合設定與常見陷阱。
程式筆記、開發心得、個人部落格
Virtual Threads 是 JDK 21 正式推出的輕量執行緒,讓 JVM 在少數 OS thread 上多工跑大量虛擬執行緒,不用再靠加大 thread pool 來撐高並發 IO。這篇從 Platform Thread 的瓶頸講起,整理 carrier thread 的 mount / unmount 機制、API 用法、pinning 問題與 JDK 24 的改善,附 Spring Boot 整合設定與常見陷阱。