Now, we would have created a data race on the local variable sum, because multiple threads might want to update it simultaneously.
现在,我们在局部变量sum上创造了一场数据竞争,因为多个线程可能同时希望更新它。
This addresses the data race, but has further costs for concurrency, since locking the entire list while iterating could block other threads from accessing the list for a long time.
这样做虽然解决了数据争用问题,但是在并发性方面付出了更多的代价,因为在迭代期间锁住整个list会阻塞其他线程,使它们在很长一段时间内不能访问这个列表。
The release and acquire have to "match" (i. e. , be performed on the same monitor) to have the right semantics. Otherwise, the code has a data race.
释放监视器和获取监视器必须匹配(也就是说要在相同的监视器上面完成这两个操作),否则,代码就会存在“数据竞争”。
Data RACES on local variables would be a new category of hazards, because we currently can always count on local-variable accesses being data-race-free.
局部变量上的数据竞争将是一种新的危险,因为我们目前始终期望局部变量访问没有数据竞争。
Data RACES on local variables would be a new category of hazards, because we currently can always count on local-variable accesses being data-race-free.
局部变量上的数据竞争将是一种新的危险,因为我们目前始终期望局部变量访问没有数据竞争。
应用推荐