ConcurrentLinkedQueue api详解

本文详细探讨了Java并发编程中的ConcurrentLinkedQueue类,通过实际单元测试,展示了其所有公共API的使用,并分析了底层实现原理。尽管目前的理解尚不全面,但已能初步掌握其主要功能。
摘要由CSDN通过智能技术生成

花了两天时间学习ConcurrentLinkedQueue api,该类是JUC原子包中的类,通过单元测试代码把所有public api方法跑了一遍,大致了解了底层实现,初学乍练,有很多一知半解的地方,待后续有了深入理解再来补充

 

package test.java.util.concurrent;


import java.util.HashSet;
import java.util.Iterator;
import java.util.Set;
import java.util.Spliterator;
import java.util.concurrent.ConcurrentLinkedQueue;
import org.junit.Test;

/**
 * ConcurrentLinkedQueue的测试类
 *
 * @date 2020-07-07 23:39:50
 */
public class ConcurrentLinkedQueueTest {
        /**
         * 无参构造函数head和tail初始化为node(null)
         * @Param
         */
        @Test
        public void testConstruct0()throws Exception{
        ConcurrentLinkedQueue testObj=new ConcurrentLinkedQueue();
                System.out.println(testObj.toString());
        }
        /**
         *通过集合初始化双向队列
         * @Param
         */
        @Test
        public void testConstruct1()throws Exception{
                Set set=new HashSet();
                set.add(3);
        ConcurrentLinkedQueue testObj=new ConcurrentLinkedQueue();
                System.out.println(testObj.toString());
        }
        /**
         *添加并返回boolean表示添加是否成功
         * 和offer处理一样
         * @Param
         */
        @Test
        public void testAdd()throws Exception{
                ConcurrentLinkedQueue testObj=new ConcurrentLinkedQueue();
                Sys
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值