- 博客(4)
- 收藏
- 关注
原创 JUC学习笔记
JUC学习笔记 ReentrantLock获取公平锁流程 final void lock() { acquire(1); } /** * Acquires in exclusive mode, ignoring interrupts. Implemented * by invoking at least once {@link #tryAcquire}, * returning on success. Otherwise the
2021-11-26 22:58:22
171
原创 HashMap为什么是2倍扩容
HashMap底层是由数组+链表(jdk1.8之后是数组+链表+红黑树)实现的。HashMap查询速度之所以快,其精髓在于数组,数组是一种n内存连续的数据结构,利用哈希值,计算出key在数组中的下标,就能帮我们迅速定位到目标数据。所以计算下标方法直接决定了hashmap的性能。 如果key的哈希值是m,hashmap容量是n,为了使数据在数组上均匀分布,必然采用取模的方法,即其下标为m%n,但这样取模性能十分低下。计算机中运算效率最高的是位运算,所以最好采用位运算。有研究发现,如果n=2^x, 恰好有m%n
2021-11-26 22:57:42
2242
原创 Spring依赖注册
Spring依赖注册 假设有ClassA和ClassC,ClassA依赖于ClassC @Component @DependsOn("c") public class A { @Autowired private B b; } @Component public class C { } Spring注册依赖关系 public class DefaultSingletonBeanRegistry extends SimpleAliasRegistry implements SingletonBean
2021-08-11 22:49:26
145
原创 MySQL学习笔记
1、ordey by 和 group by一起使用,order by字段必须出现在select和where之间,可以不是order by字段
2021-03-13 20:43:02
98
空空如也
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人