The code sample below would effectively allow one 1 thread at a time to perform. Keeping references to the threads and then calling 'Thread.join' sometime later has the same effect. How to let these threads run in such a way with the program waiting for the threads to continue independently and in parallel, and then exiting? It would appears to me that some other Kernel object signaling mechanism must be used. (In short using 'join' to tie the main thread to a secondary thread doesn't let the other threads run concurrently?)
int main() {
while (cin) {
getline(cin, input_line);
if (input_line.length()>0)
{
thread t = thread(SomeLengthyCheck, input_line);
t.join();
}
}
}
Aucun commentaire:
Enregistrer un commentaire