i am planning to start learning how to use threads.
my question is: should i first learn windows.h's functions for threading before boost to get the pattern or should i jump right to the boost threads?

ps: sry if i posted in the wrong section

Why not go for the standard threads? They have just been added to C++ (with C++11), so you might as well learn to use that. The standard thread libraries are supported (at least most of it) by most compilers. It is also almost exactly the same as the Boost.Thread library (with a few minor changes). So, if the standard thread library is not yet supported by your compiler, start getting used to the Boost.Thread library and making the switch later will be really easy.

There is no reason to learn to use the Windows threading functions (or the POSIX threading functions for that matter). These functions are C-style functions that are just a pain in the *** to work with. It is only worth knowing if you are doing more advanced kinds of multi-threading programming in which case you might want to exploit certain advanced synchronization features, in either WinAPI or pthreads, that may not be available in the standard threading library. The main OS APIs, Win32 API and POSIX (for Windows and *nix systems, respectively) differ quite fundamentally in the entrails of the OS on how they implement multi-threading (scheduling threads, kernel vs. user-side calls, interrupts, etc.) and that leads to certain synchronization, message-passing, and inter-thread communication features that are unique to either API, only if you want to exploit those additional features should you really consider learning about them.

For middle-of-the-road multi-threading, the standard or Boost thread library are very good, and inherently more portable, of course. They are also more C++-friendly because it has a pure C++ interface (as opposed to WinAPI and POSIX which have C interfaces, meaning it can get awkward to integrate it). Also, the standard or Boost thread library will usually use the most effective strategy (for synchronization and stuff) on the given platform, probably better than you could come up with if you used the API functions directly.

thx for advice mike; what's the thread library?, i only knew about windows.h threads(the as you say C-style threading)

edit: it is <thread> the library u are talking about? if yes, it seems my compiler does not support it
i am using MSVC 2010 express

I would suggest that you study the fundamental concepts involved in concurrent programming. Understanding that is the harder and the important part.

Learning to use thread facilities provided by a particular platform or library is the easy part; it gives you the tools, but you need to know when and how to use those tools.

Here are two references to get you started:
http://www.amazon.com/Synchronization-Algorithms-Concurrent-Programming-Taubenfeld/dp/0131972596
http://www.amazon.com/Art-Multiprocessor-Programming-Maurice-Herlihy/dp/0123705916

>>edit: it is <thread> the library u are talking about? if yes, it seems my compiler does not support it
i am using MSVC 2010 express

Yes, that is the library I am talking about. Use Boost.Thread if your compiler does not support this library yet.

thx

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.