When it comes to multithreaded programming, we usually start thinking of using various thread synchronization mechanisms explicitly, including use of mutexs, semaphores and conditions, etc., to control memory visibility of shared resources to multiple threads to avoid data race. For example, Boost C++ provides such mechanisms for us in its Boost.Thread.
However, in my opinion, we may be better off writing multithreaded programs for our problems without explicitly using these mechanisms, if and whenever possible. As we all know, thread synchronization comes at the cost of performance (context switches), debugging and programming complexity.
To read more about how this can be done in an executable Boost C++ multithreaded program and my line-by-line explanation of its code, please check out my blog at:
http://zhaowuluo.wordpress.com/2010/12/25/multithreading-boostasio/
Happy reading!
However, in my opinion, we may be better off writing multithreaded programs for our problems without explicitly using these mechanisms, if and whenever possible. As we all know, thread synchronization comes at the cost of performance (context switches), debugging and programming complexity.
To read more about how this can be done in an executable Boost C++ multithreaded program and my line-by-line explanation of its code, please check out my blog at:
http://zhaowuluo.wordpress.com/2010/12/25/multithreading-boostasio/
Happy reading!