This commit is contained in:
Looly 2025-06-23 19:29:25 +08:00
parent ac5abab4ea
commit e7546e6c34
2 changed files with 16 additions and 3 deletions

View File

@ -21,6 +21,7 @@ import cn.hutool.v7.core.collection.iter.ArrayIter;
import cn.hutool.v7.core.exception.CloneException;
import cn.hutool.v7.core.array.ArrayUtil;
import java.io.Serial;
import java.io.Serializable;
import java.util.Arrays;
import java.util.Iterator;
@ -37,6 +38,7 @@ import java.util.stream.StreamSupport;
* @author Looly
*/
public class Tuple implements Iterable<Object>, Serializable, Cloneable {
@Serial
private static final long serialVersionUID = -7689304393482182157L;
/**
@ -50,8 +52,17 @@ public class Tuple implements Iterable<Object>, Serializable, Cloneable {
return new Tuple(members);
}
/**
* 成员
*/
private final Object[] members;
/**
* hash值缓存
*/
private int hashCode;
/**
* 是否缓存hash值当为true时此对象的hash值只被计算一次常用于Tuple中的值不变时使用
*/
private boolean cacheHash;
/**

View File

@ -43,6 +43,7 @@ public class ThreadUtilTest {
}
}
@Test
@Disabled
public void testNewExecutorByBlockingCoefficient(){
final ThreadPoolExecutor executor = ThreadUtil.newExecutorByBlockingCoefficient(0.5f);
Console.log(executor.getCorePoolSize());
@ -92,13 +93,14 @@ public class ThreadUtilTest {
}
@Test
@Disabled
public void cyclicBarrierTest(){
//示例7个同学集齐7个龙珠7个同学一起召唤神龙前后集齐了2次
final AtomicInteger times = new AtomicInteger();
final CyclicBarrier barrier = new CyclicBarrier(7, ()->{
System.out.println(" ");
System.out.println(" ");
System.out.println("【循环栅栏业务处理】7个子线程 都收集了一颗龙珠,七颗龙珠已经收集齐全,开始召唤神龙。" + LocalDateTime.now().format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss")));
Console.log(" ");
Console.log(" ");
Console.log("【循环栅栏业务处理】7个子线程 都收集了一颗龙珠,七颗龙珠已经收集齐全,开始召唤神龙。" + LocalDateTime.now().format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss")));
times.getAndIncrement();
}); // 现在设置的栅栏的数量为2
for (int x = 0; x < 7; x++) { // 创建7个线程, 当然也可以使用线程池替换