Dear All:
I have a table T1 with these columns:
location - varchar
odd_even - varchar
I have a php page that is called from VC applications installed in 5
different locations (L1, L2, L3, L4 and L5). The page returns 0 or 1
depending on even call or odd call from each location. (1st, 3rd, 5th,
7th... page calls are odd and 2, 4, 6, 8 are even.)
The page has this logic:
select odd_even from T1 where location = '$location'
if (odd_even == 'odd')
update T1 set odd_even = 'even' where location = '$location' and
odd_even = 'odd';
return '0';
else
update T1 set odd_even = 'odd' where location = '$location' and
odd_even = 'even';
return '1';
But since each location calls the page in very quick succession (a location
have have several parallel calls running - its a multi threaded app), there
is a race condition. And at times several continuous calls return same
result (odd or even).
How do I achieve thread safety?
Please help. Its urgent.
Thanks.
Ravi.