Go4Expert

Go4Expert (http://www.go4expert.com/)
-   C (http://www.go4expert.com/forums/c/)
-   -   running two codes at the same time (http://www.go4expert.com/forums/running-codes-time-t17863/)

Andres 5Jun2009 01:33

running two codes at the same time
 
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 5Jun2009 05:27

Re: running two codes at the same time
 
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.


All times are GMT +5.5. The time now is 00:22.