
JDK
超人不会飞2018
这个作者很懒,什么都没留下…
展开
-
使用缓存提升频繁通过反射调用方法性能
getDeclaredMethod方法返回的Method对象其实都是一个新的对象,且新对象的root属性都指向原来的Method对象,如果需要频繁调用,最好把Method对象缓存起来。 测试用例 /** * @Desc: * @Author: heling * @Date: 2020/9/2 9:29 */ public class Test { public static Map<String, Method> map = new HashMap(); pub原创 2020-09-02 15:06:12 · 642 阅读 · 1 评论 -
Integer
Integer:颠覆你的认知 一、装箱拆箱 & Integer缓存 一道面试题 答案质疑 Integer.valueOf(int i)的玄机 IntegerCache 二、值传递和引用传递 一道面试题 解法一 解法二(错误) 解法三 Integer:颠覆你的认知 本文涉及的知识点:值传递和引用传递、自动装箱和拆箱、Integer缓存 一、装箱拆箱 & Integer缓存 一道面试题 ..原创 2020-06-08 00:21:38 · 215 阅读 · 0 评论 -
为何自定义线程工厂(ThreadFactory)
JDK创建线程池如果没有指定线程工厂则会使用了默认的线程工厂(DefaultThreadFactory) 既然有默认工厂,为啥还要自定义线程工厂呢?原因如下: 1.可以设置有意见的线程名,这样方便我们开发调试,问题日志查找及定位。 2.可以设置守护线程。 3.设置线程优先级 4.处理未捕获的异常: 在执行一个任务时,线程可能会由于未捕获的异常而终止,默认处理是将异常打印到控制台。但这种...原创 2019-07-03 16:04:17 · 3665 阅读 · 0 评论 -
JDK8源码阅读笔记--------java.util.LinkedList
官方文档: 链表实现list和deque接口,可以存储所有元素,包括null。该类不是同步的,如果多线程访问同一链表,并且至少有一个线程修改了,则必须外部同步。 List list = Collections.synchronizedList(new LinkedList(...)); 1.public E getFirst()、public E getLast() 2.public ...原创 2018-11-28 17:26:16 · 152 阅读 · 0 评论 -
JDK8源码阅读笔记--------java.util.ArrayList
官方文档: 该类实现list接口,属于collections,是一个动态数组,可以存放任何元素包括null,初始容量为10,添加元素时候容量可以自动增长。该类不是同步的,也就是说不是线程安全的。如果多个线程同时方位一个实例,并且其中一个修改了列表,那么必须在外在同步。我们可以包装列表如: List list = Collections.synchronizedList(new ArrayLis...原创 2018-11-28 16:59:21 · 123 阅读 · 0 评论 -
JDK8源码阅读笔记--------java.util.List
List是一个有序集合,元素可以重复,是一个接口,继承Collections接口。 1.int size(); 2.boolean isEmpty(); 3.boolean contains(Object o); 4.Iterator<E> iterator(); Returns an iterator over the elements in this list in p...原创 2018-11-28 16:38:21 · 189 阅读 · 1 评论 -
JDK8源码阅读笔记--------java.lang.Thread
A thread is a thread of execution in a program. The Java Virtual Machine allows an application to have multiple threads of execution running concurrently. Every thread has a priority. Threads with hi...原创 2018-11-22 16:54:54 · 404 阅读 · 0 评论 -
JDK8源码阅读笔记--------java.lang.StringBuffer
A thread-safe, mutable sequence of characters. A string buffer is like a String, but can be modified. At any point in time it contains some particular sequence of characters, but the length and conte...原创 2018-11-22 11:33:58 · 253 阅读 · 0 评论