Is it possible for a C/C++ program to have 2 functions running at once? For example, the program holds a for() loop while it moves onto another function?
Two functions running at once.
Collapse
X
-
-
C++ cannot have two functions running at once.
All C++ functions run sequentially, one at a time.
Now that's not to say that your C++ program won't be making operating system calls to spawn additional threads, fibers, or whatever. However, even in this case there is no concurrency UNLESS your machine has multiple processors or, lately, multiple cores.
Where there is one processor, only one thread can be active at a time. The others are blocked. Your code pretends there is concurrency and you have to program as though there were concurrency but there really isn't any.Comment
Comment