Friday, 23 August 2013

Reading a Global Variable from 2 threads Simultaneously

Reading a Global Variable from 2 threads Simultaneously

My program has 2 threads and a integer global variable. Assume that the
global variable is initialized to some value before thread2 is started its
execution. Both threads are reading from that variable. Is any race
condition possible?
These functions are executing from 2 threads simultaneously and
repetitively in my program.
void thread1(int iParam)
{
if ( gi_Varable == iParam )
//do something
}
void thread2(int iParam)
{
if ( gi_Varable == iParam)
//do something
}

No comments:

Post a Comment