mirror of
https://gitee.com/dromara/hutool.git
synced 2025-05-05 21:28:00 +08:00
fix tester bug
This commit is contained in:
parent
3b38125d4e
commit
ec60a4202d
@ -10,6 +10,7 @@
|
|||||||
|
|
||||||
### 🐞Bug修复
|
### 🐞Bug修复
|
||||||
* 【db 】 修复Oracle下别名错误造成的SQL语法啊错误(issue#I3VTQW@Gitee)
|
* 【db 】 修复Oracle下别名错误造成的SQL语法啊错误(issue#I3VTQW@Gitee)
|
||||||
|
* 【core 】 修复ConcurrencyTester重复使用时开始测试未清空之前任务的问题(issue#I3VSDO@Gitee)
|
||||||
|
|
||||||
-------------------------------------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
@ -37,6 +37,8 @@ public class ConcurrencyTester {
|
|||||||
* @return this
|
* @return this
|
||||||
*/
|
*/
|
||||||
public ConcurrencyTester test(Runnable runnable) {
|
public ConcurrencyTester test(Runnable runnable) {
|
||||||
|
this.sf.clearWorker();
|
||||||
|
|
||||||
timeInterval.start();
|
timeInterval.start();
|
||||||
this.sf//
|
this.sf//
|
||||||
.addRepeatWorker(runnable)//
|
.addRepeatWorker(runnable)//
|
||||||
@ -47,6 +49,23 @@ public class ConcurrencyTester {
|
|||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 重置测试器,重置包括:
|
||||||
|
*
|
||||||
|
* <ul>
|
||||||
|
* <li>清空worker</li>
|
||||||
|
* <li>重置计时器</li>
|
||||||
|
* </ul>
|
||||||
|
*
|
||||||
|
* @return this
|
||||||
|
* @since 5.7.2
|
||||||
|
*/
|
||||||
|
public ConcurrencyTester reset(){
|
||||||
|
this.sf.clearWorker();
|
||||||
|
this.timeInterval.restart();
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 获取执行时间
|
* 获取执行时间
|
||||||
*
|
*
|
||||||
|
@ -197,6 +197,9 @@ public class SyncFinisher {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 任务内容
|
||||||
|
*/
|
||||||
public abstract void work();
|
public abstract void work();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,10 +1,10 @@
|
|||||||
package cn.hutool.core.thread;
|
package cn.hutool.core.thread;
|
||||||
|
|
||||||
import org.junit.Ignore;
|
import cn.hutool.core.date.DateUtil;
|
||||||
import org.junit.Test;
|
|
||||||
|
|
||||||
import cn.hutool.core.lang.Console;
|
import cn.hutool.core.lang.Console;
|
||||||
import cn.hutool.core.util.RandomUtil;
|
import cn.hutool.core.util.RandomUtil;
|
||||||
|
import org.junit.Ignore;
|
||||||
|
import org.junit.Test;
|
||||||
|
|
||||||
public class ConcurrencyTesterTest {
|
public class ConcurrencyTesterTest {
|
||||||
|
|
||||||
@ -18,4 +18,19 @@ public class ConcurrencyTesterTest {
|
|||||||
});
|
});
|
||||||
Console.log(tester.getInterval());
|
Console.log(tester.getInterval());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
@Ignore
|
||||||
|
public void multiTest(){
|
||||||
|
ConcurrencyTester ct = new ConcurrencyTester(5);
|
||||||
|
for(int i=0;i<3;i++){
|
||||||
|
Console.log("开始执行第{}个",i);
|
||||||
|
ct.test(() -> {
|
||||||
|
// 需要并发测试的业务代码
|
||||||
|
Console.log("当前执行线程:" + Thread.currentThread().getName()+" 产生时间 "+ DateUtil.now());
|
||||||
|
ThreadUtil.sleep(RandomUtil.randomInt(1000, 3000));
|
||||||
|
});
|
||||||
|
}
|
||||||
|
Console.log("全部线程执行完毕 "+DateUtil.now());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user