#include <xtd/collections/generic/list>
#include <xtd/threading/interlocked>
#include <xtd/threading/semaphore>
#include <xtd/threading/thread>
#include <xtd/console>
#include <xtd/startup>
namespace mutex_example {
class program {
public:
static void main() {
for(
auto i = 1;
i <= 5; ++
i) {
threads.emplace_back(worker);
}
pool.release(3);
}
static void worker(std::any num) {
"and waits for the semaphore.", num);
pool.wait_one();
num, pool.release());
}
private:
inline static int padding;
};
}
Represents a strongly typed list of objects that can be accessed by index. Provides methods to search...
Definition list.hpp:79
static void write_line()
Writes the current line terminator to the standard output stream using the specified format informati...
static int32 add(int32 &location, int32 value) noexcept
Adds two 32-bit integers and replaces the first integer with the sum, as an atomic operation.
Limits the number of threads that can access a resource or pool of resources concurrently.
Definition semaphore.hpp:38
static void sleep(int32 milliseconds_timeout)
Suspends the current thread for a specified time.
static void join_all()
Blocks the calling thread until all joinable threads terminate.
#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
@ i
The I key.
Definition console_key.hpp:104
The xtd::collections::generic namespace contains interfaces and classes that define generic collectio...
Definition comparer.hpp:16
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