#include <xtd/threading/event_wait_handle>
#include <xtd/threading/interlocked>
#include <xtd/threading/thread>
#include <xtd/console>
#include <xtd/startup>
class example {
private:
inline static int64 thread_count = 0;
public:
static void main() {
for (
auto i = 0;
i <= 4;
i++) {
threads_[
i] =
thread {thread_proc};
}
}
}
for(
auto i = 0;
i <= 4;
i++) {
threads_[
i] =
thread {thread_proc};
}
}
}
private:
static void thread_proc(std::any
data) {
clear_count.set();
}
inline static std::array<thread, 5> threads_;
};
static xtd::string read_line()
Reads the next line of characters from the standard input stream.
static void write_line()
Writes the current line terminator to the standard output stream using the specified format informati...
Represents a thread synchronization event.
Definition event_wait_handle.hpp:37
bool set()
Sets the state of the event to signaled, allowing one or more waiting threads to proceed.
static int64 read(int64 &location) noexcept
Returns a 64-bit value, loaded as an atomic operation.
static int32 increment(int32 &location) noexcept
Increments a specified variable and stores the result, as an atomic operation.
static int32 decrement(int32 &location) noexcept
Decrements a specified variable and stores the result, as an atomic operation.
Creates and controls a thread, sets its priority, and gets its status.
Definition thread.hpp:45
static void sleep(int32 milliseconds_timeout)
Suspends the current thread for a specified time.
void start()
Causes the operating system to change the state of the current instance to xtd::threading::thread_sta...
static bool signal_and_wait(wait_handle &to_signal, wait_handle &to_wait)
Signals one xtd::threading::wait_handle and waits on another.
virtual bool wait_one()
Blocks the current thread until the current xtd::threading::wait_handle receives a signal.
#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:167
@ auto_reset
When signaled, the xtd::threading::event_wait_handle resets automatically after releasing a single th...
Definition event_reset_mode.hpp:26
@ manual_reset
When signaled, the xtd::threading::event_wait_handle releases all waiting threads and remains signale...
Definition event_reset_mode.hpp:28
int64_t int64
Represents a 64-bit signed integer.
Definition int64.hpp:23
type_t as(any_object &o)
Casts a type into another type.
Definition __as_any_object.hpp:59
@ i
The I key.
Definition console_key.hpp:104
The xtd::threading namespace provides classes and interfaces that enable multithreaded programming....
Definition abandoned_mutex_exception.hpp:10
The xtd namespace contains all fundamental classes to access Hardware, Os, System,...
Definition abstract_object.hpp:8
constexpr const_pointer data() const noexcept
Gets direct access to the underlying contiguous storage.
Definition read_only_span.hpp:201