Skip to Content
Java의 현대적 동시성
book

Java의 현대적 동시성

by A N M Bazlur Rahman
September 2025
Beginner to intermediate
336 pages
5h 57m
Korean
O'Reilly Media, Inc.
Content preview from Java의 현대적 동시성

7장. 가상 스레드를 활용하는 최신 프레임워크

이 작품은 AI를 사용하여 번역되었습니다. 여러분의 피드백과 의견을 환영합니다: translation-feedback@oreilly.com

미래를 예측하는 가장 좋은 방법은 미래를 발명하는 것입니다.

Alan Kay

JDK 21에 가상 스레드가 도입되면서 Java 에코시스템은 프레임워크가 동시성을 처리하는 방식에 큰 변화를 겪었습니다. 많은 최신 프레임워크가 성능, 확장성 및 리소스 효율성을 개선하기 위해 가상 스레드를 도입했습니다.

이 장에서는 Spring Boot, Quarkus, Jakarta EE와 같은 주요 프레임워크가 가상 스레드를 어떻게 통합하고 있는지 살펴보겠습니다. 그러나 관심 있는 분들이 각 프레임워크를 직접 심층적으로 살펴보는 것을 선호할 것으로 생각되므로 이러한 프레임워크의 내부 작동 방식에 대해서는 다루지 않겠습니다.

시작하겠습니다.

Spring Boot

Spring Boot는 Java 에코시스템에서 엔터프라이즈 애플리케이션을 구축하기 위한 사실상의 프레임워크 중 하나입니다.

역사적으로 Spring Boot 웹 애플리케이션은 주로 전용 플랫폼 스레드가 들어오는 각 클라이언트 요청을 처리하는 요청별 스레드 모델을 따랐습니다. 이 접근 방식은 적당한 부하에서는 잘 작동하지만, 이러한 요청이 항상 플랫폼 스레드를 통해 제공되기 때문에 대량의 동시 I/O 바운디드 요청을 처리할 때는 확장성 문제가 발생합니다.

이를 완화하기 위해 Spring Boot는 다음과 같은 어노테이션과 함께 비동기 프로그래밍 기능을 도입했습니다. @Async 와 같은 어노테이션과 TaskExecutor. 그러나 이 접근 방식은 다음 예에서 볼 수 있듯이 여전히 제한된 플랫폼 스레드 풀에 의존하고 있습니다:

@Configuration
public class ThreadPoolConfig {
    @Bean
    public AsyncTaskExecutor applicationTaskExecutor() {
        
        ThreadPoolTaskExecutor executor = new ThreadPoolTaskExecutor();
        executor.setCorePoolSize(10);
        executor.setMaxPoolSize(100);
        executor.initialize();
        return executor;
    }
}

여기서 모든 요청이나 작업은 유한한 풀의 스레드를 사용하므로 부하가 많을 때 성능 병목 현상이 발생할 수 있습니다.

2023년 11월, Spring Framework 6.1을 기반으로 하는 Spring Boot 3.2가 출시되면서 가상 스레드를 완성한 Java 21에 대한 공식 지원이 도입되었습니다. Java 17은 여전히 기본 JDK로 유지되지만, 이제 Java 21은 프레임워크 내에서 최고 수준의 런타임 환경으로 취급됩니다. 이 지원의 중요한 측면은 가상 스레드를 활성화하기 위한 간단한 구성 속성을 제공한다는 것입니다:

# application.properties
spring.threads.
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.

Read now

Unlock full access

More than 5,000 organizations count on O’Reilly

AirBnbBlueOriginElectronic ArtsHomeDepotNasdaqRakutenTata Consultancy Services

QuotationMarkO’Reilly covers everything we've got, with content to help us build a world-class technology community, upgrade the capabilities and competencies of our teams, and improve overall team performance as well as their engagement.
Julian F.
Head of Cybersecurity
QuotationMarkI wanted to learn C and C++, but it didn't click for me until I picked up an O'Reilly book. When I went on the O’Reilly platform, I was astonished to find all the books there, plus live events and sandboxes so you could play around with the technology.
Addison B.
Field Engineer
QuotationMarkI’ve been on the O’Reilly platform for more than eight years. I use a couple of learning platforms, but I'm on O'Reilly more than anybody else. When you're there, you start learning. I'm never disappointed.
Amir M.
Data Platform Tech Lead
QuotationMarkI'm always learning. So when I got on to O'Reilly, I was like a kid in a candy store. There are playlists. There are answers. There's on-demand training. It's worth its weight in gold, in terms of what it allows me to do.
Mark W.
Embedded Software Engineer

You might also like

머신러닝 시스템 설계

머신러닝 시스템 설계

칩 후옌
이펙티브 러스트

이펙티브 러스트

데이비드 드라이스데일
자바 개발자를 위한 데브옵스 툴

자바 개발자를 위한 데브옵스 툴

스티븐 친, 멜리사 맥케이, 익스헬 루이츠, 바루크 사도구르스키

Publisher Resources

ISBN: 9798341670174