c++11使用线程

由浅入深

#include<thread>
#include<iostream>

using namespace std;

//无参线程
void thread_t1()
{
    cout<<"hello c++11 thread"<<endl;
}

//带参线程
void thread_arg(const int a,const int b)
{
    cout<< "a=" << a <<" b=" << b <<endl;
}

int main()
{
    thread t(thread_t1);
    thread_t1(thread_arg,5,6);

    t.join();    //等待子线程结束
    t1.join();

    cout<<"this is main"<<endl;

    return 0;
}
发布了133 篇原创文章 · 获赞 175 · 访问量 15万+

猜你喜欢

转载自blog.csdn.net/c_shell_python/article/details/102541696