Category : multithreading

Here is my code: #include <atomic> #include <thread> #include <vector> int num_of_threads = 4; // Simple function for incrementing an atomic int void work(std::atomic<int>& a) { for (int i = 0; i < 100000; i++) { a++; } } void test() { std::atomic<int> a; a = 0; std::vector<std::thread> threads; threads.reserve(num_of_threads); for (size_t i = 0; ..

Read more

I have tried compiling my C++ File with #include <thread> using G++, but it failed. Here is my source code below: #include <iostream> #include <thread> #include <windows.h> using namespace std; void act_1() { cout << "Hello World from act_1n"; return; } int main() { thread th(act_1); th.join(); ExitProcess(EXIT_SUCCESS); } Now, I have used the flags ..

Read more