|
|
- #include <thread>
- #include <iostream>
-
- volatile int counter=0;
-
- void incr(const int count=200000)
- {
- for(int i=0;i<count;i++)
- counter++;
- }
-
- int main()
- {
- std::thread m(incr,200000);
- incr(200000);
- std::cout << "Expects 400000, get "<< counter <<std::endl;
- return 0;
- }
|