My multithread program works slowly or appear deadlock on dual core machine, please help
Posted
by Shangping Guo
on Stack Overflow
See other posts from Stack Overflow
or by Shangping Guo
Published on 2010-05-04T00:17:01Z
Indexed on
2010/05/04
0:28 UTC
Read the original article
Hit count: 276
multithreading
I have a program with several threads, one thread will change a global when it exits itself and the other thread will repeatedly poll the global. No any protection on the globals. The program works fine on uni-processor. On dual core machine, it works for a while and then halt either on Sleep(0) or SuspendThread(). Would anyone be able to help me out on this?
The code would be like this:
Thread 1:
do something...
while(1)
{
.....
flag_thread1_running=false;
SuspendThread(GetCurrentThread());
continue;
}
Thread 2
....
while(flag_thread1_running==false) Sleep(0);
....
© Stack Overflow or respective owner