#include<iostream>
#include<thread>
volatile int a = 0;
int main() {
std::thread([] {
while (1) {
a++;
}
}).detach();
std::thread([] {
while (1) {
std::cout << a << std::endl;
}
}).detach();
while (1);
return 0;
}
多线程共享数据
最新推荐文章于 2024-10-08 00:02:21 发布