摘要:
##1. synchronized实现双线程交替打印 class Print implements Runnable{ static int i=0; static final int n=100; @Override public void run() { synchronized (this) 阅读全文
摘要:
##线程池核心方法execute()解析: public void execute(Runnable command) {//#1 if (command == null) throw new NullPointerException(); int c = ctl.get(); if (worker 阅读全文
摘要:
首先我们要知道,在理想情况下的哈希表中,哈希函数生成的哈希值是value在数组中的下标,其范围是分布于负无穷到正无穷的整个实整数轴的。而在现实情况下,是不可能存在这么大的一个数组的。接下来分析HashMap怎么处理: HashMap的put方法: public V put(K key, V valu 阅读全文