Shows how to use xtd::threading::monitor::pulse_all method.
#include <xtd/threading/thread>
#include <xtd/console>
#include <xtd/lock>
#include <xtd/startup>
 
 
namespace monitor_lock_example {
  class program {
  public:
    static void main() {
      auto t1 = thread::start_new(worker);
      auto t2 = thread::start_new(worker);
      
      thread::sleep(1000);
      
        monitor::pulse_all("lock");
      }
      
      thread::join_all({t1, t2});
    }
    
  private:
    static void worker() {
        console::write_line("    Thread {} wait...", thread::current_thread().managed_thread_id());
        monitor::wait("lock");
        console::write_line("    Thread {} ...continue.", thread::current_thread().managed_thread_id());
      }
    }
  };
}
 
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:175
 
#define lock_(object)
The lock_ keyword marks a statement block as a critical section by obtaining the mutual-exclusion loc...
Definition lock.hpp:85
 
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