Can you use the boost::mutex libraries to protect a critical section of code when you are not using boost::thread but instead using the MFC threading capability via AfxBeginThread? If so, are there any problems with doing this?
Asked
Active
Viewed 635 times
2 Answers
1
A (real) thread is a (real) thread.
Boost makes no special assumptions about the fact that a thread has been created directly (Windows API) or via Boost.
Short answer:
No problem.

curiousguy
- 8,038
- 2
- 40
- 58
0
Yes, you can. There is no problem since both are using the Win32 API behind the scenes.

Simon
- 1,496
- 8
- 11
-
"Boost is _using the Win32 API behind the scenes_" That was my first reaction, but technically this is not strictly sufficient: you must check that Boost does not keeps a list of threads created via Boost somewhere just to forbid the use of `boost::mutex` in a thread not created with Boost! (Boost does not do that, indeed.) – curiousguy Oct 22 '11 at 20:22