Is there a good tutorial on working with (programming) threads in Visual Studio 2005? Not MFC related, just native C++ (no .NET).
C does not contain any built-in support for multithreaded applications. Instead, it relies entirely upon the operating system to provide this feature. This tutorial assumes that you are working on Linux OS and we are going to write multi-threaded C program using POSIX.
C is a language that runs on one thread by default, which means that the code will only run one instruction at a time.
pthread_t is the data type used to uniquely identify a thread. It is returned by pthread_create() and used by the application in function calls that require a thread identifier.
4.2. Windows. On Windows machines, there's no limit specified for threads. Thus, we can create as many threads as we want, until our system runs out of available system memory.
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.
You may take a look at the following OpenMP tutorials. 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".
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With