C++基础-swap交换线程

使用swap进行两个线程的交换 

#include<thread>
#include<iostream>

using namespace std;
//交换线程
int main1()
{
    thread t1([](){cout << "fangfang"<<endl;});
    thread t2([](){cout << "huahua"<<endl;});
    cout << "t1.get_id()" << t1.get_id() << "t2.get_id()" << t2.get_id() << endl;
    swap(t1, t2);
    cout << "t1.get_id()" << t1.get_id() << "t2.get_id()" << t2.get_id() << endl;
    t1.join();
    t2.join();
}
原文地址:https://www.cnblogs.com/my-love-is-python/p/14966222.html