引用自 http://blog.sina.com.cn/s/blog_508938e10102v1ig.html

//make thread-safe list
  List MyStrList = Collections.synchronizedList(new ArrayList());
  MyStrList.add("123");
  MyStrList.add("abc");
  //make thread-safe hashset
  Set set=Collections.synchronizedSet(new HashSet());
  set.add(123);
  set.add(456);
  //make thread-safe hashmap
  Map map=Collections.synchronizedMap(new HashMap());
  map.put(1, "thb");
  map.put(12, "bill tang");

 

CopyOnWriteArrayList与Collections.synchronizedList的性能对比

http://blog.csdn.net/zljjava/article/details/48139465

 

相关文章:

  • 2021-09-12
  • 2022-01-06
  • 2021-06-02
  • 2021-12-06
  • 2021-08-20
  • 2021-09-24
  • 2022-12-23
  • 2021-04-05
猜你喜欢
  • 2021-09-17
  • 2022-12-23
  • 2022-12-23
  • 2021-04-13
  • 2021-10-25
  • 2021-05-31
相关资源
相似解决方案