2024年9月1日

ReentrantReadWriteLock源码剖析

摘要: ReentrantReadWriteLock源码剖析 synchronized和ReentrantLock都是互斥锁。 为什么要出现读写锁:如果说有一个操作是读多写少的,还要保证线程安全的话。如果采用上述的两种互斥锁,效率方面很 定是很低的。在这种情况下,咱们就可以使用ReentrantReadWr 阅读全文

posted @ 2024-09-01 14:20 ~码铃薯~ 阅读(14) 评论(0) 推荐(0)

ReentrantLock源码剖析

摘要: ReentrantLock源码剖析 测试案例: public class ReentrantLockDemo { // ReentrantLock lock = new ReentrantLock(); // 默认是非公平锁 // ReentrantLock lock = new Reentrant 阅读全文

posted @ 2024-09-01 13:32 ~码铃薯~ 阅读(13) 评论(0) 推荐(0)

ConditionObject源码剖析

摘要: ConditionObject源码剖析 这玩意是AQS的一个内部类。 案例演示: public class ReentrantLockConditionDemo { ReentrantLock lock = new ReentrantLock(); Condition condition = loc 阅读全文

posted @ 2024-09-01 10:43 ~码铃薯~ 阅读(13) 评论(0) 推荐(0)

导航