debug vs. release
Hi!
I am using the Microsoft Visual Studio to build a program that has several threads. The threads communicate among them reading a shared variable; thus, a thread is waiting: "while (variable == 0);", until other thread puts the variable into 1. That occurs more than one time in the program, and everything works fine in the Debug version. However, the Release version does not get out from the while bucle. I have tried some changes like:
while (variable == 0)
{
cout << ".";
}
instead of the previous:
while (variable == 0);
And it works fine in this way. I would like to know why this happens, whether there is any conflict between the variables or why, perhaps, the condition is not read again and again.
Although the program works, I would like to remove all these couts. Anybody knows how I could improve this problem?
Thank you very much,
xagutxu
|