I'm creating a vector that contains vectors of integers, the idea is to sort each vector of integers by calling the bubble sort with threads for each one and then print the time of execution.
I'm trying to implement a thread in each iteration but doesn't work
vector<int> bubbleSort(vector<int>); void asynchronousSort(vector<vector<int>> pool){ double executionTime; clock_t tStart = clock(); for(int i = 0; i < pool.size(); i++){ thread t (bubbleSort, pool[i]); t.join(); } executionTime = (double)(clock() - tStart)/CLOCKS_PER_SEC; cout << "Time :" << executionTime<< "s." << endl ; } void synchronousSort(vector<vector<int>> pool){ double executionTime; clock_t tStart = clock(); for(int i = 0; i < pool.size(); i++){ pool[i] = bubbleSort(pool[i]); } executionTime = (double)(clock() - tStart)/CLOCKS_PER_SEC; cout << "Time :" << executionTime<< "s." << endl ; } int main(int argc, const char * argv[]) { int selectMethod; vector<vector<int>> pool(10); //Create 10 lists with 10000 numbers in decrement. for (int i = 0; i < 10; i++) { vector<int> temp; for(int j = 10000; j > 0; j--){ temp.push_back(j); } pool.push_back(temp); } cout << "Select method 1)Asynchronously. 2)Synchronously. (1/2): "; cin >> selectMethod; if(selectMethod == 1){ asynchronousSort(pool); }else{ synchronousSort(pool); } return 0; } It's taken the same time in both methods, when sinchronousSort must be more fast.