• 134 并发容器类~list set queue


    arraylist:

         底层object数组,

         ensureCapcityInternal 判断是否数组扩容

    copyonwritearraylist:

         copyonwrite机制:

               当进行资源写入时,系统生成资源副本进行修改。保证写入原子性。写入加锁

    hashset:

           底层实现:hashmap K+new Object

    copyonwriteArraySet:

           底层:copyonwritearraylist

            添加元素前判断数据是否存在

    concurrentskiplistset:

            底层:concurrentSkiplistMap

    Queue:

        add:队列已满抛异常

        remove(element):队列为空抛异常

        offer:添加失败返回false

        poll(peek):如果没有返回null

        put:如果队列满了就阻塞

        take: 队列为空则阻塞

    ArrayBlockingQueue:

         循环数组: putindex takeindex

    LinkedBlockingQueue:

         底层 链表。因为链表 所以可以不指定长度(无穷长)

    ConcurrentLinkedQueue:

         没有阻塞方法put、take,cas操作实现高并发+线程安全

          容量无限

    SynchronoursQueue:

         容量为0  同步队列 有进有出~    常见cachedExecutor

    PriorityBlockingQueue:

        优先级队列  不是先进先出。 可以传入比较器 定义优先级规则

       

  • 相关阅读:
    2019第17周日
    完成胜过完美
    系统可扩展设计方法之消息队列
    mac下使用brew安装java等应用
    mac下zsh的使用:主题、z命令
    PyCharm中Python代码提示:Shadows name from outer scope
    python垃圾回收杂谈
    Python垃圾回收机制及gc模块详解:内存泄露的例子
    aa
    python的内存回收机制即gc模块讲解
  • 原文地址:https://www.cnblogs.com/windghost/p/12342695.html
Copyright © 2020-2023  润新知