# Java 21의 Virtual Threads 소개 [48p 슬라이드]

> Clean Markdown view of GeekNews topic #19240. Use the original source for factual precision when an external source URL is present.

## Metadata

- GeekNews HTML: [https://news.hada.io/topic?id=19240](https://news.hada.io/topic?id=19240)
- GeekNews Markdown: [https://news.hada.io/topic/19240.md](https://news.hada.io/topic/19240.md)
- Type: news
- Author: [xguru](https://news.hada.io/@xguru)
- Published: 2025-02-15T10:34:01+09:00
- Updated: 2025-02-15T10:34:01+09:00
- Original source: [drive.google.com](https://drive.google.com/file/d/1-IyvNP_S8tmF0zCkvSqIqmEGS_CfTByI/view)
- Points: 17
- Comments: 2

## Summary

Java 21의 Virtual Threads는 기존의 Platform Threads와 비교하여 차단 없이 작동하는 방식을 제공합니다. Virtual Threads를 사용할 때는 CompletableFuture 대신 Virtual Threads를 사용하고, Thread Pool 대신 newThreadPerTaskExecutor를 사용하는 것이 권장됩니다. 또한, Spring Boot와의 통합을 통해 MVC와 비동기 작업에서 Virtual Threads를 활용할 수 있으며, 기존 시스템에 Virtual Threads를 적용하는 방법도 설명합니다.

## Topic Body

- Virtual Threads 개요  
  - Virtual Threads (Loom project) 란  
  - Platform Threads vs Virtual Threads - Blocking ?  
  - Platform Threads 작동 방식  
  - Virtual Threads 작동 방식  
- Rules & Best practices  
  - Rule 1 - Create Threads  
  - Rule 2 - Do Not use CompletableFuture  
  - Rule 2 - Do use Virtual Threads  
  - Rule 3 - Do not use Thread Pool  
  - Rule 3 - Do use newThreadPerTaskExecutor  
  - Rule 4 - Do not use FixedThreadPool for concurrency  
  - Rule 4 - Do use Semaphore for Concurrency  
  - Rule 5 - Do use ScopedValue  
  - Rule 6 - Do use ReentranceLock instead of synchronized  
  - Rule 7 - Do Structured Concurrency  
  - Rule 8 - Test Virtual Threads  
- Spring Boot with Virtual Threads  
  - Spring Boot MVC with Virtual Threads  
  - Spring Boot MVC Async Tasks  
  - RestController use Virtual Threads  
- Legacy Code 변경  
  - 기존 시스템에 Virtual Threads 적용하기

## Comments



### Comment 34600

- Author: click
- Created: 2025-02-15T12:49:54+09:00
- Points: 2

Jdk24에서 synchronized가 더이상 pinning을 발생시키지 않도록 수정되어서 rule 6도 다음 LTS 쯤에는 필요없을겁니다.

### Comment 34598

- Author: carnoxen
- Created: 2025-02-15T11:49:35+09:00
- Points: 1

[Scoped Value](https://openjdk.org/jeps/487), [Structured Concurrency](https://openjdk.org/jeps/8340343)는 아직 "미리 보기" 단계라서 Virtual Thread가 상용화되기까진 좀 오래 걸릴 것 같습니다.
