今天时间学习Phaser api,该类是JUC原子包中的类,通过单元测试代码把所有public api方法跑了一遍,大致了解了底层实现,初学乍练,有很多一知半解的地方,待后续有了深入理解再来补充
package test.java.util.concurrent;
import java.util.concurrent.Phaser;
import java.util.concurrent.TimeUnit;
import org.junit.Test;
/**
* Phaser的测试类
*
* @date 2020-07-26 23:25:11
*/
public class PhaserTest {
/**
*无参构造函数
* @Param
*/
@Test
public void testConstruct0()throws Exception{
Phaser testObj=new Phaser();
System.out.println(testObj.toString());
}
/**
*初始化参与者数量
* @Param
*/
@Test
public void testConstruct1()throws Exception{
Phaser testObj=new Phaser(3);
System.out.println(testObj.toString());
}
/**
* 通过指定phaser初始化
* @Param
*/
@Test
public void testConstruct2()throws Exc