87

从底层看锁的实现-Java邵先生的博客

 4 years ago
source link: https://blog.51cto.com/13904503/2416126
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
以下内容针对互斥锁。为什么需要锁?锁代表着对临界区的访问权限。只有获得锁的操作对象,才能进入临界区。锁的本质是什么?锁的本质是一个数据结构(或者说是一个对象),这个对象内保留着描述锁所需要的必要信息。如当前锁是否已被占用,被哪个线程占用。而锁的一些工具,函数库,实际上就是对一个锁对象的信息进行变更。上锁操作=>尝试对锁对象的信息进行修改,如果修改成功,则程序继续向下执行,否则将暂时停留在此。

About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK