c:c_threads:thread_safe_function
Table of Contents
C - C++ Threads - Thread safe function
thread_safe_function.hpp
#pragma once #include <string> void thread_safe_function(std::string str);
thread_safe_function.cpp
#include "thread_safe_function.hpp" #include <string> #include <iostream> #include <mutex> std::mutex mtx; void thread_safe_function(std::string str) { std::lock_guard<std::mutex> lck(mtx); std::cout << str << std::endl; }
References
c/c_threads/thread_safe_function.txt · Last modified: 2021/04/28 09:31 by peter