That is correct. However, multithreaded programming in C++ is actually quite a complex topic because of race conditions with shared data.
I don't recommend it for beginners. Often times, beginners think they need a 2nd thread to do something, when really it could (and should) all be done in one thread.
EDIT:
For example:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
|
//global string object:
string example = "";
// a function running in one thread
void thread_a()
{
example = "foo";
}
// a function running in a second thread
void thread_b()
{
example = "bar";
cout << example;
}
|
Assume that both threads are running at more or less the same time. What do you expect line 14 to output?
a: foo
b: bar
c: random garbage
d: program crash
e: memory leak
The answer is: any of the above. If 'example' is getting poked and prodded by multiple threads at the same time, things get
very bad and pretty much anything can happen. This is especially bad with std::string because it's a complex class that manages memory, so it might lead to memory corruption, leaks, crashes, etc.
So yeah -- complex topic. Before you dive in and start adding threads... ask yourself if you really need to.