
Modern C++ Thread 간결하게 사용하기
·
C++/기초
#include #include #include #include #include #include using namespace std::chrono_literals;void ThreadFunction(int threadNumber, std::latch& latch) { for (int i{ 0 }; i threads; for (int i{ 0 }; i std::jthread를 사용합니다. 이는 C++20에서 도입된 새로운 스레드 클래스로, 자동으로 join을 수행하며 취소 요청을 지원합니다.std::latch를 사용하여 모든 스레드의 완료를 동기화합니다. 이는 C++20에서 도입된 새로운 동기화 프리미티브입니다.std::format을 사용하여 문자열 포매팅을 수행합니다. 이는 C++20의 새..