Shows how to use xtd::threading::countdown_event class.
#include <xtd/xtd>
namespace monitor_lock_example {
class program {
public:
static void main() {
auto countdown_event = threading::countdown_event {5};
auto thread_proc = [&] {
console::write_line("Thread {} signals countdown_event", thread::current_thread().managed_thread_id());
countdown_event.signal();
};
for (auto i = 0; i < 5; ++i)
thread::start_new(thread_proc);
countdown_event.wait();
console::write_line("All threads have signaled countdown_event");
}
};
}
startup_(monitor_lock_example::program::main);
#define startup_(main_method)
Defines the entry point to be called when the application loads. Generally this is set either to the ...
Definition startup.hpp:168