//********************************************************
// The following code example is taken from the book
//  C++23 - The Complete Guide
//  by Nicolai M. Josuttis (www.josuttis.com)
//  https://www.cppstd23.com
//
// The code is licensed under a
//  Creative Commons Attribution 4.0 International License
//  https://creativecommons.org/licenses/by/4.0/
//********************************************************


#include <print>
#include <thread>

int main()
{
  auto printThreadID = [] {
    std::println("We are in thread {:15}", std::this_thread::get_id());
  };

  // print main thread ID:
  printThreadID();

  // starts threads that print their thread ID:
  std::jthread t1{printThreadID};
  std::jthread t2{printThreadID};

  // wait for the end of the threads:
  t1.join();
  t2.join();
}

