parallel_for_each


// print_array complie with: /EHsc
#include 
#include 
#include 
#include 

using namespace Concurrency;
using namespace std;
using namespace std::tr1;


int main()
{
    array<int, 3> a = {13, 26, 39};
    cout << "Using for_each:" << endl;
    for_each(a.begin(), a.end(), [&](int n){ cout << n << endl;} );

    // 使用 parallel_for_each来完成同样的任务
    cout << "Using parallel_for_each:" << endl;
    parallel_for_each(a.begin(), a.end(), [&](int n) {cout << n << endl;} );

    system("pause");
    return 0;
}

你可能感兴趣的:(C++)