A parallel for using std::thread?
问题 I'm new with std::thread and I try to code a parallel_for . I coded the following thing: // parallel_for.cpp // compilation: g++ -O3 -std=c++0x parallel_for.cpp -o parallel_for -lpthread // execution: time ./parallel_for 100 50000000 // (100: number of threads, 50000000: vector size) #include <iostream> #include <iomanip> #include <cstdlib> #include <vector> #include <thread> #include <cmath> #include <algorithm> #include <numeric> #include <utility> // Parallel for template<typename Iterator