views:

5467

answers:

4

Hello all,

does anyone know a good tutorial on working with (programming) threads in Visusal Studio 2005? Not MFC related, just native C++ (no .NET)

Thanks

+3  A: 

Win32 Multithreaded Programming

http://www.amazon.com/Win32-Multithreaded-Programming-Aaron-Cohen/dp/1565922964

Also try some of the free undergraduate podcasts on operating systems. You can find theoretical discussions on locking, multithreading, etc. (the one I know of is from Berkeley and is based on JAva, but still relevant)

http://webcast.berkeley.edu/course_feeds.php?semesterid=18

Tim
That book seems to be out of print.
Jonke
oops. I have it and like it. Sorry about the "bad" link
Tim
Apparently one can still purchase it through amazon though.
Tim
I love that book myself, and have used their C++ wrappers in a number of programs in the past.
crashmstr
Ok, I think there are some small examples in the http://www.amazon.com/Windows-Programming-Addison-Wesley-Microsoft-Technology/dp/0321256190/ref=pd_bxgy_b_text_b as well. Not in any c++ but just win32 api calls from C.
Jonke
+3  A: 

Try one of these articles on codeproject.com:

http://www.codeproject.com/KB/threads/threadobject.aspx

http://www.codeproject.com/KB/winsdk/Win32_Event_Handling.aspx

kenny
+8  A: 

Instead of using Win32 threads directly, I'd consider using a thread wrapper such as Boost threads. These are cross platform so porting your application later will be easier.

Tom Leys
Good idea! Do you know a good tutorial about them?
jilles de wit
yup. http://www.ddj.com/cpp/184401518
gbjbaanb
Thanks for answering that one for me gbjbaanb!
Tom Leys
+5  A: 

You may take a look at https://computing.llnl.gov/tutorials/openMP/. This doesn't concern all concepts of multithreading in VC++, but OpenMP only, which VC++ supports. OpenMP is easy to use in some simple cases of multithreading, for instance independent iterations in loop, independent blocks of code which can be executed concurrently. Although OpenMP is not so flexible in comparison with other approaches but it is very easy to use.

To enable OpenMP you need to switch it on in the project properties "C/C++/Language/OpenMP Support"

sergdev
A big advantage of systems like OpenMp is that it is much easier to create a large number of threads to do your work, making your application scale to the multi-cores of the future.
Tom Leys