集合框架关系类图(数据结构)


一张图知道所有

1.HashMap,TreeMap 是线程不安全的

2. HashTable 和 ConcurrentHashMap 都是线程安全的。区别在于他们对加锁的范围不同,HashTable 对整张Hash表进行加锁,而ConcurrentHashMap将Hash表分为16桶(segment),每次只对需要的桶进行加锁。
3. Collections 类提供了synchronizedXxx()方法,可以将指定的集合包装成线程同步的集合。比如,
List  list = Collections.synchronizedList(new ArrayList());
Set  set = Collections.synchronizedSet(new HashSet());

相关文章:

  • 2022-01-09
  • 2021-12-03
  • 2022-12-23
  • 2021-12-17
  • 2022-12-23
  • 2021-09-01
猜你喜欢
  • 2021-06-21
  • 2021-08-03
  • 2021-09-23
  • 2021-06-12
  • 2022-12-23
相关资源
相似解决方案