Threading in C++ or executing multiple functions/instances at same time?

I wanna execute more than one function or instace at the same time?
Can enybody guide me about this topic?
I think this process known as threading but not conformed.
Yes, it's called threading or multi-threading. The CPU power is divided into smaller parts, threads, that each run their own processes. The C++ language doesn't provide threading functionality, so you have to use a library for it. TBB (threading building blocks) is such a library, a rather elaborate one. Here you can find everything you need:
closed account (zb0S216C)
Just to update Fransje's reply: the C++ Standard Committee has standardised Boost's threading library in C++11; it's now known as "std::thread"[1]. If you haven't got a C++11-compliant compiler, you may as well use the threading library used by the standard: Boost[2]


Last edited on
only available for C++11, though.
Multithreading is an extremely complex topic, especially in C++. There are many "gotchas" and pitfalls that will trip up beginners. C++ makes it especially dangerous because it doesn't automatically build in thread safety measures into objects like some other languages do.

I highly recommend you do not touch C++ multithreading until you are very familiar with the language.

I also find that when newbies think they need multithreading, they really don't. More often than not the task they want to do can easily be accomplished by doing things serially, rather than in parallel.

Perhaps if you can give us an example of what you're trying to do, we can suggest a simple way to do it without adding the complexities and problems of multithreading.
Thanks for guiding me budies.
Last edited on
Topic archived. No new replies allowed.