You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
Uh oh!
There was an error while loading. Please reload this page.
-
Spring Boot에서 발생할 수 있는 동시성 문제와 Virtual Threads를 활용한 해결
Spring Boot에서는 다양한 동시성 문제가 발생할 수 있음, 그 원인은 스레드 관리, 차단 I/O 작업, 리소스 공유 문제 등으로 나뉨.
1. 주요 동시성 문제 예시
1.1 파일 처리에서의 동시성 문제
문제 상황
문제 코드
1.2 메일 발송 작업에서의 동시성 문제
문제 상황
문제 코드
1.3 스케줄링 작업에서의 동시성 문제
문제 상황
문제 코드
2. Virtual Threads를 활용한 해결
2.1 파일 처리에서 Virtual Threads 적용
해결 코드
코드 설명
Executors.newVirtualThreadPerTaskExecutor()를 사용해 Virtual Threads로 차단 I/O를 분리.CompletableFuture로 파일 읽기 작업을 비동기적으로 처리.2.2 메일 발송 작업에서 Virtual Threads 적용
해결 코드
코드 설명
2.3 스케줄링 작업에서 Virtual Threads 적용
해결 코드
코드 설명
3. Virtual Threads 적용 결과
4. 결론
Copyright © 2024 Saewon Shim All rights reserved.
Beta Was this translation helpful? Give feedback.
All reactions