Open wangpeipei90 opened 2 years ago
void loopin_func(const std::string& thread_name) { thread_local A* a; a = creatA(); std::lock_guard<std::mutex> lock(cout_mutex); std::cout << "thread[" << thread_name << "]: a.counter:" << a->get_value() << std::endl; return; }
对应的输出应为
create A thread[t1]: a.counter:0 create A thread[t1]: a.counter:0 create A thread[t1]: a.counter:0 create A thread[t2]: a.counter:0 create A thread[t2]: a.counter:0 create A thread[t2]: a.counter:0
对应的输出应为