【发布时间】:2013-11-13 15:20:08
【问题描述】:
在 C 中我有:
double balance;
void deposit(double amount)
{balance = balance +amount;}
机器语言:
load R1, balance
load R2, amount
add R1, R2
store R1, balance
如果变量 balance 包含 500 并且两个线程同时运行程序分别存入 300 和 200,这怎么会有问题呢?以及如何使用并发机制使这个过程线程安全?
【问题讨论】:
标签: c multithreading concurrency system theory