c++11多线程

#include 
#include 
#include 
#include 

using namespace std;
void test(int a,int b)
{
    for (size_t i = 0; i < 5; i++)
    {
        cout << a <<"  "< endl;
        Sleep(100);
    }
}

int main(int argc, char* argv[])
{

    vector vT;

    for (size_t i = 0; i < 10; i++)
        vT.push_back(thread(test, i,i+100));

    for (size_t i = 0; i < 10; i++)
        vT[i].join();

    system("pause");
    return 0;
}

 

转载于:https://www.cnblogs.com/tiandsp/p/9059558.html

你可能感兴趣的:(c++11多线程)