线程的创建-1

来源:互联网 发布:深圳编程培训机构 编辑:程序博客网 时间:2024/05/29 16:58
#include <iostream>
#include <thread>
using namespace std;
void my_thread()
{
    puts("hello, world");
}
int main(int argc, char* argv[])
{
    thread t(my_thread);//实例化一个线程对象t,参数my_thread是一个函数,在线程创建完成后将被执行
    t.join();//等待子线程my_thread执行完之后,主线程才可以继续执行下去,此时主线程会释放掉执行完后的子线程资源。

    system("pause");
    return 0;
}
0 0
原创粉丝点击