Race Conditions
Overview
The General Race Condition Problem
function withdraw($amount)
{
$balance = getBalance();
if ($amount <= $balance)
{
$balance = $balance - $amount;
echo "You have withdrawn: $amount";
saveBalance($balance);
// Give money to customer (code omitted)
}
else
{
echo "Insufficient funds.";
}
}Reference
Last updated