thread
创建线程,不会阻塞主线程
thread成员函数
void thread::join();阻塞线程,当前线程执行完毕才会往下执行
bool thread::joinble();线程是否可以连接,返回
void thread::detach();分离主线程和子线程的关联
void printI()
{
for (size_t i = 0; i < 100; i++)
{
std::cout << i << std::endl;
}
std::cout << std::endl;
}
int main()
{
std::thread thread1(printI);
if (thread1.joinable())
thread1.join();//
std::cout << "over\n";
return 0;
}
标签:11,thread,--,void,主线,阻塞,线程,多线程 From: https://blog.51cto.com/u_16071993/7364370