Shows how to use xtd::threading::jthread class.
#include <xtd/xtd>
auto main() -> int {
auto thread_proc = [] {
thread::current_thread().name("thread_proc");
for (auto index = 0; index < 10; ++index, thread::sleep(100_ms))
console::write_line(" ({}) index = {}", thread::current_thread().name(), index);
};
thread::current_thread().name("main");
console::write_line("({}) begin", thread::current_thread().name());
block_scope_(
auto thread1 = jthread::start_new(thread_proc)) {
}
console::write_line("({}) end", thread::current_thread().name());
}
#define block_scope_(...)
The specified expression is cleared automatically when the scope is ended.
Definition block_scope.hpp:25