std::thread::join
De cppreference.com
|
|
This page has been machine-translated from the English version of the wiki using Google Translate.
The translation may contain errors and awkward wording. Hover over text to see the original version. You can help to fix errors and improve the translation. For instructions click here. |
<metanoindex/>
<tbody> </tbody> void join(); |
(depuis C++11) | |
Bloque le thread actuel jusqu'à ce que le thread identifié par
*this termine son exécution .Original:
Blocks the current thread until the thread identified by
*this finishes its execution.The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
You can help to correct and verify the translation. Click here for instructions.
Paramètres
(Aucun)
Original:
(none)
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
You can help to correct and verify the translation. Click here for instructions.
Retourne la valeur
(Aucun)
Original:
(none)
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
You can help to correct and verify the translation. Click here for instructions.
Exceptions
std::system_error si
joinable() == false ou une erreur se produit .Original:
std::system_error if
joinable() == false or an error occurs.The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
You can help to correct and verify the translation. Click here for instructions.
Exemple
#include <iostream>
#include <thread>
#include <chrono>
void foo()
{
// simulate expensive operation
std::this_thread::sleep(std::chrono::seconds(1));
}
void bar()
{
// simulate expensive operation
std::this_thread::sleep(std::chrono::seconds(1));
}
int main()
{
std::cout << "starting first helper...\n";
std::thread helper1(foo);
std::cout << "starting second helper...\n";
std::thread helper2(bar);
std::cout << "waiting for helpers to finish...\n";
helper1.join();
helper2.join();
std::cout << "done!\n";
}
Résultat :
starting first helper...
starting second helper...
waiting for helpers to finish...
done!
Voir aussi
permet au thread de s'exécuter indépendamment de son handle Original: permits the thread to execute independently from the thread handle The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. (fonction membre publique) | |
vérifie si le fil est joignable, soit potentiellement s'exécute dans un contexte parallèle Original: checks whether the thread is joinable, i.e. potentially running in parallel context The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. (fonction membre publique) | |