Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

2019-12-10:谈一谈java线程安全的集合有哪些? #208

Open
MoJieBlog opened this issue Dec 10, 2019 · 2 comments
Open

2019-12-10:谈一谈java线程安全的集合有哪些? #208

MoJieBlog opened this issue Dec 10, 2019 · 2 comments
Labels

Comments

@MoJieBlog
Copy link
Collaborator

最近找题要找好久。更新有点不及时,抱歉。

@Moosphan Moosphan added the Java label Dec 10, 2019
@feelschaotic
Copy link

  1. 早期的线程安全集合
  • Vector
    = 全部方法加 synchronized 的 ArrayList
  • HashTable
    = 全部方法加 synchronized 的 HashMap
  1. 包装工具类
  • Collections.synchronizedXXX()
    在原集合的基础上添加了锁对象,集合中的每个方法都通过这个锁对象实现同步
  1. java.util.concurrent包
  • ConcurrentHashMap
    1.7 分段锁技术,1.8 对table每行首元素加锁
  • CopyOnWriteXXXX
    加了写锁,写的时候锁住的整个对象,读则可以并发执行
  1. 其他
  • Stack
    继承了 Vector

@senlinxuefeng
Copy link

补充
BlockingQueue

StringBuffer

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

4 participants