Creating a named thread is working well for me:
void DoMany( int iTimes ) {
for ( int i = 0; i < iTimes; i++ )
DoOne();
}
int main( int nArg, const char* apszArg[] ) {
std::thread t1( DoMany, 100 );
:
:
But I can't figure out how to do it when creating the threads without a name. This produces an error that it cannot resolve the constructor. I'm also wondering whether, once that is working, whether the vector's type will be the right type or whether instead of thread*
I need to specify template arguments and if so how to do so for 1) the function and 2) the parameter list.
vector<thread*> apthread;
for ( int i = 0; i < nThreads; i++ )
apthread.push_back( new thread( DoMany, i ) );
Aucun commentaire:
Enregistrer un commentaire