#include <xtd/threading/countdown_event>
#include <xtd/threading/thread>
#include <xtd/console>
#include <xtd/startup>
 
 
namespace monitor_lock_example {
  class program {
  public:
    static void main() {
      auto thread_proc = [&] {
        console::write_line("Thread {} signals countdown_event", thread::current_thread().managed_thread_id());
      };
      
      for (auto i = 0; i < 5; ++i)
        thread::start_new(thread_proc);
      
      console::write_line("All threads have signaled countdown_event");
    }
  };
}
 
startup_(monitor_lock_example::program::main);
 
 
Represents a synchronization primitive that is signaled when its count reaches zero.
Definition countdown_event.hpp:30
 
void wait()
Blocks the current thread until the xtd::threading::countdown_event is set.
 
bool signal()
Registers a signal with the xtd::threading::countdown_event, decrementing the value of xtd::threading...
 
#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:175
 
The xtd::threading namespace provides classes and interfaces that enable multithreaded programming....
Definition abandoned_mutex_exception.hpp:11
 
The xtd namespace contains all fundamental classes to access Hardware, Os, System,...
Definition xtd_about_box.hpp:10