void Function_1()
{
std::cout << "study thread" << std::endl;
std::cout << "Function_1Thread 1" << std::endl;
std::cout << "Function_1Thread 2" << std::endl;
std::cout << "Function_1Thread 3" << std::endl;
std::cout << "Function_1Thread 4" << std::endl;
std::cout << "Function_1Thread 5" << std::endl;
std::cout << "Function_1Thread 6" << std::endl;
std::cout << "study thread end" << std::endl;
}
int main()
{
std::thread t1(Function_1);
std::cout << "T1Thread ID :" << t1.get_id() << std::endl;
t1.detach();
//t1.join();
std::cout << "MainThread ID :" << std::this_thread::get_id() << std::endl;
std::cout << "MainThread 1" << std::endl;
std::cout << "MainThread 2" << std::endl;
std::cout << "MainThread 3" << std::endl;
std::cout << "MainThread 4" << std::endl;
std::cout << "MainThread 5" << std::endl;
std::cout << "MainThread 6" << std::endl;
return 0;
}
不应该输出是混乱的吗?
– 逆光也很美 5年前