关于我们

质量为本、客户为根、勇于拼搏、务实创新

< 返回新闻公共列表

集合

发布时间:2023-06-26 13:59:57

    集合

    • 集合关系图(展示基本情况)
    • List
      • ArrayList如何保证线程安全?
        • 修改为使用Vector, 性能会下降
        • 使用Collections.synchronizedCollection()
        • 直接加锁
      • ArrayList与Vector的区别;前者线程不安全,扩容为1.5倍;后者线程安全,扩容为2倍
      • Vector是方法级别的锁,而synchronizedCollection是变量级别的锁,一般使用后者,性能会强于Vector
      • LinkedList如何保证线程安全?
        • 使用Collections.synchronizedList();
      • Collections方法本质上是对基础对象的增强,属于设计模式中装饰者模式的使用
    对象名称具体实现线程是否安全
    ArrayList动态数组,随机访问不安全
    LinkedList双向链表不安全
    Vector动态数组安全
    • Set
      • 如何保证线程安全:
        • Collections.synchronizedSet()
    对象名称具体实现线程是否安全是否有序
    TreeSet基于Map不安全
    HashSet基于HashMap不安全
    LinkedHashSet双向链表不安全
    • Queue
    对象名称具体实现线程是否安全
    LinkedList基于链表不安全
    PriorityQueue基于堆不安全

    /template/Home/leiyu/PC/Static