DoubleAdder api詳解

今天學習DoubleAdder類,該類是JUC原子包中的類,通過單元測試代碼把所有public api方法跑了一遍,大致瞭解了底層實現

 

package test.java.util.concurrent.atomic;


import java.util.concurrent.atomic.DoubleAdder;
import org.junit.Test;

/**
 * DoubleAdder的測試類
 *
 * @author zqw
 * @date 2020-06-20 23:34:54
 */
public class DoubleAdderTest {
        /**
        * 無參構造函數
         * void
         * @Param
         * @author zhqwm
         * @date 2020/6/20 23:52
         */
        @Test
        public void testConstruct0()throws Exception{
                DoubleAdder testObj=new DoubleAdder();
                System.out.println(testObj.toString());
        }
        /**
         * 加上對應參數值
         * void
         * @Param
         * @author zhqwm
         * @date 2020/6/20 23:52
         */
        @Test
        public void testAdd(){
                DoubleAdder testObj=new DoubleAdder();
                testObj.add(32);
                System.out.println(testObj.toString());
        }
        /**
         * 求和
         * void
         * @Param
         * @author zhqwm
         * @date 2020/6/20 23:52
         */
        @Test
        public void testSum(){
                DoubleAdder testObj=new DoubleAdder();
                testObj.add(32);
                System.out.println(testObj.sum());
                System.out.println(testObj.toString());
        }
        /**
         * 重置
         * void
         * @Param
         * @author zhqwm
         * @date 2020/6/20 23:52
         */
        @Test
        public void testReset(){
                DoubleAdder testObj=new DoubleAdder();
                testObj.add(32);
                System.out.println(testObj.toString());
                testObj.reset();
                System.out.println(testObj.toString());
        }
        /**
         * 求和然後重置
         * void
         * @Param
         * @author zhqwm
         * @date 2020/6/20 23:52
         */
        @Test
        public void testSumThenReset(){
                DoubleAdder testObj=new DoubleAdder();
                testObj.add(32);
                System.out.println(testObj.sumThenReset());
                System.out.println(testObj.toString());
        }
        /**
         * toString
         * void
         * @Param
         * @author zhqwm
         * @date 2020/6/20 23:52
         */
        @Test
        public void testToString(){
                DoubleAdder testObj=new DoubleAdder();
                System.out.println(testObj.toString());
        }
        /**
         * 獲取double值
         * void
         * @Param
         * @author zhqwm
         * @date 2020/6/20 23:52
         */
        @Test
        public void testDoubleValue(){
                DoubleAdder testObj=new DoubleAdder();
                System.out.println(testObj.doubleValue());
        }
        /**
         * 獲取long值
         * void
         * @Param
         * @author zhqwm
         * @date 2020/6/20 23:52
         */
        @Test
        public void testLongValue(){
                DoubleAdder testObj=new DoubleAdder();
                System.out.println(testObj.longValue());
        }
        /**
         * 獲取int值
         * void
         * @Param
         * @author zhqwm
         * @date 2020/6/20 23:52
         */
        @Test
        public void testIntValue(){
                DoubleAdder testObj=new DoubleAdder();
                System.out.println(testObj.intValue());
        }
        /**
         * 獲取float值
         * void
         * @Param
         * @author zhqwm
         * @date 2020/6/20 23:52
         */
        @Test
        public void testFloatValue(){
                DoubleAdder testObj=new DoubleAdder();
                System.out.println(testObj.floatValue());
        }



}
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章