Boost.Atomic
프로그래밍 언어/boost 2015. 4. 30. 13:49
boost::atomic정수, 포인터 타입에 대한 산술 연산을 원자적(최소의 접근)으로 가능하게 하는 템플릿 클래스volatile, interlocked 를 내부적으로 지원하므로 간결하고 사용이 쉽다 Colored By Color Scripter™123456789101112131415161718192021222324#include "stdafx.h" #include #include boost::atomic a{ 0 }; void thread(){ ++a;} int _tmain(int argc, _TCHAR* argv[]){ boost::thread t1{ thread }; boost::thread t2{ thread }; t1.join(); t2.join(); std::cout