如何锁定我的线程,以便我的输出不是这样的:你好......你好...... hheelhllelolo.l..o ......
std::size_t const nthreads=5;
std::vector<std::thread> my_threads(nthreads);
for(unsigned i=0;i<nthreads;i++)
{
my_threads[i] = std::thread ([] () {std::cout << "hello...";});
}
Run Code Online (Sandbox Code Playgroud)