dimanche 22 décembre 2019

C++11: Passing vector elements as threads into thread functions

Is there any way to pass each element of a vector as a thread into a function? I tried the following approach and commented out the error. The program is supposed to take in a line of variables(e.g 1 2 3 4 5 6 7) and pass each variable as a thread into the thread function.

I would be very grateful for any help regarding this!

int main()
{
    cout<<"[Main] Please input a list of gene seeds: "<<endl;
    int value;
    string line;
    getline(cin, line);
    istringstream iss(line);
    while(iss >> value){
       inputs.push_back(value);
    }

    for (int unsigned i = 0; i < inputs.size(); i++) {
    //thread inputs.at(i)(threadFunction);
    }

Aucun commentaire:

Enregistrer un commentaire