std::this_thread:: get_id
      From cppreference.net
     
     
     
        
         C++
        
        
         
          
           
          
          
         
        
       
       
        
         Concurrency support library
        
        
         
          
           
            
          
          
          
         
        
       
       
              
  | 
             
              
  | 
            |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 
           
           Défini dans l'en-tête
            
         
            
             <thread>
            
           
           | 
         ||
| 
           
           
            
             
              std::
              
               thread
              
              
               ::
              
              
               id
              
             
            
            get_id
            
             (
            
            
             )
            
            
             noexcept
            
            
             ;
            
           
           
          | 
         (depuis C++11) | |
Retourne l' id du thread actuel.
         Table des matières | 
       
Paramètres
(aucun)
Valeur de retour
id du thread actuel.
Exemple
         Exécuter ce code
        
       #include <chrono> #include <iostream> #include <syncstream> #include <thread> using namespace std::chrono_literals; void foo() { std::thread::id this_id = std::this_thread::get_id(); std::osyncstream(std::cout) << "thread " << this_id << " sleeping...\n"; std::this_thread::sleep_for(500ms); } int main() { std::jthread t1{foo}; std::jthread t2{foo}; }
Sortie possible :
thread 140113018054400 sleeping... thread 140113009661696 sleeping...
Voir aussi
| 
         retourne l'
         
          id
         
         du thread
          (fonction membre publique de 
           std::thread
          
          )
         
         | 
       |
| 
          
          
           
            Documentation C
           
          
          pour
          
           
            thrd_current
           
          
          
         | 
       |