1 Star 0 Fork 2.8K

韵律浮尘/asyncTool

forked from 京东零售/asyncTool 
加入 Gitee
与超过 1400万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
TestSequentialTimeout.java 2.04 KB
一键复制 编辑 原始数据 按行查看 历史
wuweifeng10 提交于 2020-03-23 14:24 +08:00 . 将test放到test下
package seq;
import com.jd.platform.async.executor.Async;
import com.jd.platform.async.executor.timer.SystemClock;
import com.jd.platform.async.wrapper.WorkerWrapper;
import java.util.concurrent.ExecutionException;
/**
* 串行测试
* @author wuweifeng wrote on 2019-11-20.
*/
@SuppressWarnings("Duplicates")
public class TestSequentialTimeout {
public static void main(String[] args) throws InterruptedException, ExecutionException {
testFirstTimeout();
}
/**
* begin-1576719450476
* callback worker0 failure--1576719451338----worker0--default-threadName:main
* callback worker1 failure--1576719451338----worker1--default-threadName:main
* callback worker2 failure--1576719451338----worker2--default-threadName:main
* end-1576719451338
* cost-862
*/
private static void testFirstTimeout() throws ExecutionException, InterruptedException {
SeqWorker1 w1 = new SeqWorker1();
SeqWorker2 w2 = new SeqWorker2();
SeqTimeoutWorker t = new SeqTimeoutWorker();
WorkerWrapper<String, String> workerWrapper2 = new WorkerWrapper.Builder<String, String>()
.worker(w2)
.callback(w2)
.param("2")
.build();
WorkerWrapper<String, String> workerWrapper1 = new WorkerWrapper.Builder<String, String>()
.worker(w1)
.callback(w1)
.param("1")
.next(workerWrapper2)
.build();
//2在1后面串行
//T会超时
WorkerWrapper<String, String> workerWrapperT = new WorkerWrapper.Builder<String, String>()
.worker(t)
.callback(t)
.param("t")
.next(workerWrapper1)
.build();
long now = SystemClock.now();
System.out.println("begin-" + now);
Async.beginWork(5000, workerWrapperT);
System.out.println("end-" + SystemClock.now());
System.err.println("cost-" + (SystemClock.now() - now));
Async.shutDown();
}
}
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
Java
1
https://gitee.com/JavaLead/asyncTool.git
git@gitee.com:JavaLead/asyncTool.git
JavaLead
asyncTool
asyncTool
master

搜索帮助