75

同步锁-奔跑吧爽爽的博客-51CTO博客

 6 years ago
source link: http://blog.51cto.com/13579086/2067180
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.
neoserver,ios ssh client
1.产生线程安全的问题的原因当多条语句操作同一线程的共享数据时,一个线程对多条语句值执行了一部分,还没执行完,另一个线程参与进来执行,导致共享数据时错误的2.解决办法对多条操作共享数据的语句,执行完毕,才能放弃cpu的执行权,需要通过锁对象来完成3.锁对象的原理持有锁对象线程可以在同步中执行,没有锁的线程及时获取cpu的执行权,也进步去,因为没有锁4.同步的前提必须有两个或两个以上的线程必须是多个

About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK