上一页 1 2 3 4 5 6 ··· 9 下一页
摘要: 1.参数说明 acc:上下文 corePoolSize:核心工作线程 maximumPoolSize:最大工作数量线程,包含了核心工作线程 keepAliveTime:非核心线程最大空闲回收时间 TimeUnit:指定keepAliveTime时间单位 workQueue:工作队列。如事件都让可用的 阅读全文
posted @ 2024-08-15 10:55 辉辉、 阅读(8) 评论(0) 推荐(0) 编辑
摘要: 1.初始化 2.就绪 - 运行中 存在就绪是因为CPU有时间片,一个线程无法一直运行,需要切换到就绪,等待获得CPU执行时间片。 3.阻塞 synchronized 4.等待 object.wait(); object.join(); 唤醒通过 object.notify(); object.not 阅读全文
posted @ 2024-08-14 20:05 辉辉、 阅读(3) 评论(0) 推荐(0) 编辑
摘要: 1添加源码 final V putVal(K key, V value, boolean onlyIfAbsent) { if (key == null || value == null) throw new NullPointerException(); int hash = spread(key 阅读全文
posted @ 2024-08-14 16:17 辉辉、 阅读(4) 评论(0) 推荐(0) 编辑
摘要: 1.开放寻址法 出现hash冲突,一直寻找可用的hash地址,直到找到不冲突的地址即可。 2.链地址法 参考hashMap 3.在哈希法 一旦出现哈希冲突,更换函数方法。知道找到不冲突的哈希值 4.一致性哈希法 分布式一致性哈希算法,将哈希归纳到不同位置上,近可能均匀,减少冲突。 阅读全文
posted @ 2024-08-14 15:36 辉辉、 阅读(73) 评论(0) 推荐(0) 编辑
摘要: subList是arrayList的内部类 private class SubList extends AbstractList<E> implements RandomAccess { private final AbstractList<E> parent; private final int 阅读全文
posted @ 2024-08-14 15:28 辉辉、 阅读(3) 评论(0) 推荐(0) 编辑
摘要: public class LRUCache { int cap; LinkedHashMap<Integer, Integer> linkedHashMap = new LinkedHashMap<>(); LRUCache(int cap){ this.cap = cap; } public in 阅读全文
posted @ 2024-08-14 15:23 辉辉、 阅读(5) 评论(0) 推荐(0) 编辑
摘要: ArrayList:是数组数据结构,扩容是通过扩容数组。可快速访问其中一个元素或修改。 ListedList:是链表数据结构,可高效的实现中间元素修改/删除。但是访问没有数组高效。 vector:是强同步的ArrayList ArrayList扩容步骤 1.判断申请的元素后,元素数量超过现有容量。 阅读全文
posted @ 2024-08-14 15:16 辉辉、 阅读(4) 评论(0) 推荐(0) 编辑
摘要: 删除集合方法 public static void main(String[] args) { ArrayList<Integer> arrayList = new ArrayList(); arrayList.add(1); arrayList.add(2); arrayList.add(3); 阅读全文
posted @ 2024-08-14 14:55 辉辉、 阅读(5) 评论(0) 推荐(0) 编辑
摘要: 1.fail-fast(快速失败) 比如程序执行到1/0的时候,无法进行计算。则直接抛出异常,进行提示。 如HashMap中,添加一个新的元素后,modCount会增加。modCount会传递给创建迭代器,而迭代器会维护expectedModCount,则使用迭代器期间只能通过迭代器修改。否则直接促 阅读全文
posted @ 2024-08-14 14:47 辉辉、 阅读(6) 评论(0) 推荐(0) 编辑
摘要: 1.源码全集如下 查看代码 public class HashMap<K,V> extends AbstractMap<K,V> implements Map<K,V>, Cloneable, Serializable { @java.io.Serial private static final l 阅读全文
posted @ 2024-08-14 12:18 辉辉、 阅读(38) 评论(0) 推荐(0) 编辑
上一页 1 2 3 4 5 6 ··· 9 下一页
点击右上角即可分享
微信分享提示