I have core quad computer so threads can run in parallel on different cores, but what I'm getting as an output is:Code:#include <iostream> #include <fstream> #include <conio.h> #include <process.h> using namespace std; unsigned int __stdcall foo(void *param) { while(1) cerr<<"howdeee\n"; return 0; } unsigned int __stdcall foo2(void *param) { while(1) cerr<<"NOOOOOOOOO\n"; return 0; } void main() { _beginthreadex(NULL,0,foo,NULL,0,0); _beginthreadex(NULL,0,foo2,NULL,0,0); while(1) cerr<<"FORk\n"; }
howdeee
FORk
NOOOOOOOOO
in this pattern repeating for ever, thats not what I expexted I expected them to be randomly printed mabe two howdeee then a FORk then NOOOOOOOO then maybe a FORk ect... since threads run in parallel :S. but as is it seems they are running serially foo then main then foo2 any ideas of why this is happening?
thanks in advance




Reply With Quote