
java并发编程
进入JUC
DragonSmith
为理想而奋斗终生,别给机会不中用!
守正笃实久久为功!
展开
-
通过ThreadPoolExecutor的方式创建线程池
线程池(重点)阿里巴巴开发手册,线程池不允许使用Executors去创建,而是通过ThreadPoolExecutor的方式。线程池:三大方法、七大参数、4种拒绝策略线程池的好处:降低资源消耗,提高响应速度;因为创建和销毁十分消耗资源方便管理**小结:**线程复用,可以控制最大并发数、管理线程三大方法:/** * Executors 工具类 */public class Demo01 { public static void main(String[] arg原创 2022-03-18 23:54:15 · 4109 阅读 · 0 评论 -
ConcurrentModificationException异常
ConcurrentModificationException异常ArrayList集合是不安全的,将list集合的add操作放到线程中,结果报ConcurrentModificationException异常(并发修改异常)public class ListTest { public static void main(String[] args) { List<String> list = new ArrayList<String>();原创 2022-03-17 18:45:11 · 494 阅读 · 0 评论