mirror of
https://gitee.com/dromara/hutool.git
synced 2025-06-28 13:34:09 +08:00
fix test
This commit is contained in:
parent
ac5abab4ea
commit
e7546e6c34
@ -21,6 +21,7 @@ import cn.hutool.v7.core.collection.iter.ArrayIter;
|
|||||||
import cn.hutool.v7.core.exception.CloneException;
|
import cn.hutool.v7.core.exception.CloneException;
|
||||||
import cn.hutool.v7.core.array.ArrayUtil;
|
import cn.hutool.v7.core.array.ArrayUtil;
|
||||||
|
|
||||||
|
import java.io.Serial;
|
||||||
import java.io.Serializable;
|
import java.io.Serializable;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.Iterator;
|
import java.util.Iterator;
|
||||||
@ -37,6 +38,7 @@ import java.util.stream.StreamSupport;
|
|||||||
* @author Looly
|
* @author Looly
|
||||||
*/
|
*/
|
||||||
public class Tuple implements Iterable<Object>, Serializable, Cloneable {
|
public class Tuple implements Iterable<Object>, Serializable, Cloneable {
|
||||||
|
@Serial
|
||||||
private static final long serialVersionUID = -7689304393482182157L;
|
private static final long serialVersionUID = -7689304393482182157L;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -50,8 +52,17 @@ public class Tuple implements Iterable<Object>, Serializable, Cloneable {
|
|||||||
return new Tuple(members);
|
return new Tuple(members);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 成员
|
||||||
|
*/
|
||||||
private final Object[] members;
|
private final Object[] members;
|
||||||
|
/**
|
||||||
|
* hash值缓存
|
||||||
|
*/
|
||||||
private int hashCode;
|
private int hashCode;
|
||||||
|
/**
|
||||||
|
* 是否缓存hash值,当为true时,此对象的hash值只被计算一次,常用于Tuple中的值不变时使用。
|
||||||
|
*/
|
||||||
private boolean cacheHash;
|
private boolean cacheHash;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -43,6 +43,7 @@ public class ThreadUtilTest {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
@Test
|
@Test
|
||||||
|
@Disabled
|
||||||
public void testNewExecutorByBlockingCoefficient(){
|
public void testNewExecutorByBlockingCoefficient(){
|
||||||
final ThreadPoolExecutor executor = ThreadUtil.newExecutorByBlockingCoefficient(0.5f);
|
final ThreadPoolExecutor executor = ThreadUtil.newExecutorByBlockingCoefficient(0.5f);
|
||||||
Console.log(executor.getCorePoolSize());
|
Console.log(executor.getCorePoolSize());
|
||||||
@ -92,13 +93,14 @@ public class ThreadUtilTest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
@Disabled
|
||||||
public void cyclicBarrierTest(){
|
public void cyclicBarrierTest(){
|
||||||
//示例:7个同学,集齐7个龙珠,7个同学一起召唤神龙;前后集齐了2次
|
//示例:7个同学,集齐7个龙珠,7个同学一起召唤神龙;前后集齐了2次
|
||||||
final AtomicInteger times = new AtomicInteger();
|
final AtomicInteger times = new AtomicInteger();
|
||||||
final CyclicBarrier barrier = new CyclicBarrier(7, ()->{
|
final CyclicBarrier barrier = new CyclicBarrier(7, ()->{
|
||||||
System.out.println(" ");
|
Console.log(" ");
|
||||||
System.out.println(" ");
|
Console.log(" ");
|
||||||
System.out.println("【循环栅栏业务处理】7个子线程 都收集了一颗龙珠,七颗龙珠已经收集齐全,开始召唤神龙。" + LocalDateTime.now().format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss")));
|
Console.log("【循环栅栏业务处理】7个子线程 都收集了一颗龙珠,七颗龙珠已经收集齐全,开始召唤神龙。" + LocalDateTime.now().format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss")));
|
||||||
times.getAndIncrement();
|
times.getAndIncrement();
|
||||||
}); // 现在设置的栅栏的数量为2
|
}); // 现在设置的栅栏的数量为2
|
||||||
for (int x = 0; x < 7; x++) { // 创建7个线程, 当然也可以使用线程池替换。
|
for (int x = 0; x < 7; x++) { // 创建7个线程, 当然也可以使用线程池替换。
|
||||||
|
Loading…
Reference in New Issue
Block a user