Synchronize access to shared mutable data
来源:互联网 发布:mac打开不被认证的app 编辑:程序博客网 时间:2024/06/05 17:35
The synchronized keyword ensures that only a single thread will execute a statement or block at a time.
Many programmers think of synchronization solely as a means of mutual exclusion, to prevent an object from being observed in an inconsistent state
while it is being modified by another thread.
The view is correct, but it doesn't tell the whole story.
Not only dose synchronization prevent a thread from observing an ojbect in an inconsistent state, but it also ensures that
objects progress from consistent state to consistent state by an orderly sequence of state transitions that appear to execute sequentially.
Every thread entering a synchronized method or block sees the effects of all previous state transitions controlled by the same lock.
After a thread exits the synchronized region, any thread that enters a region synchronized by the same lock sees the state transition caused by that thread, if any.
You may hear it said that to improve performance, you should avoid the use of synchronization when reading or writing atomic data. This advice is dangerously wrong.
Sysnchronization is required for reliable communication between threads as well as for mutual exclusion.
In summary, whenever multiple threads share mutable data, each thread that reads or writes the data must obtain a lock.
- Synchronize access to shared mutable data
- How to synchronize access to a shared resource in a multithreading environment by using Visual C#
- Mutable Access of To-Many Relationships
- Access to shared folders in Virtual Box
- How to access 2 dimensions SAFEARRAY data
- Coursera Using python to access Web data
- How to access data/data folder in Android device?
- [PHP] Shared memory access
- synchronize
- Using Xalan's XPath API to Access XML Data
- Server configuration denies access to data source问题的解决
- Add data to the Access database using ADO
- HP/H3C and Huawei SNMP Weak Access to Critical Data
- [c#] How to use Data Access Application Block?
- How to access pixel data of an image
- FunDA(0)- Functional Data Access accessible to all
- 2016.12.8 Using Python to Access Web Data
- Coursera Using python to access Web data quiz 3
- 结构之法 算法之道 博客地址 --- 对各种面试题的收集整理
- Android中Activity的生命周期
- 乔布斯时代结束
- VIM for windows + ctags + taglist + winmanager
- struts constant
- Synchronize access to shared mutable data
- Java语言实现的各种排序源代码--快速排序
- iphone自定义view
- 乔布斯:在人间
- java堆栈(转)
- Linux Server Deployment(IV)SSH private/public key
- webdriver常用技巧(java)
- 各种排序代码 .
- 我喜欢你,很久了。等你,也很久了。现在,我要离开,比很久很久还要久……