lst-1004-godb.cpp
//#(compile) c++; compiler:g132; options:-O3 -std=c++23; libs:-
// https://godbolt.org/z/Kv84eb96E
#include <iostream>
#include <thread>
#include <chrono>
using namespace std::chrono; // seconds, suffix s
auto makeThread(std::string wer) {
return std::jthread{ [wer] {
std::this_thread::sleep_for(1s);
std::cout << "Viel Glueck, " << wer << std::endl;
} };
}
int main() {
auto th = makeThread("Jim"); // Ausgabe: Viel Glueck, Jim
th.join();
}