running two codes at the same time

Andres's Avatar, Join Date: Jul 2008
Go4Expert Member
Is there a way to run two codes in a program at the same time. For example, I have this program that is getting information from two things.
Lets just say something like the following:

cin>>data from mouse;
cin>>data from other device;

Does the program get capture receive the information from top to bottom or does it get both info at the same time. My problem is that I am not sure that the info is being processed at the same time. I need to be sure since I want it to be in real time. Can someone please help me please. Is there a code to process both information at the same time.
xpi0t0s's Avatar, Join Date: Aug 2004
Mentor
You can only run two operations at the same time if you have more than one CPU.
However there are approximations. Look up "multithreading". It's a lot of fun.
Or if you prefer to keep to a single thread, you could check one for input, then check the other, then do whatever other stuff the program is supposed to do, and so on.