赞
踩
Disruptor为什么这么快
Disruptor不使用锁,通过内存屏障和原子性的CAS操作替换锁
锁机制:
悲观锁:读写的时候都严格加锁,高并发下锁竞争问题严重,性能低下。
乐观锁:读的时候不加锁、写的时候才加锁;性能有所提高,但是会引起读写不一致的问题。
缓存基于数组而不是链表,用位运算替代求模。缓存的长度总是2的N次方,这样可以用位运算i&(length-1) 替代i%length
去伪共享,CPU的缓存一般是以缓存行为最小单位的,对应主存的一块相应大小的单元;当前的缓存行大小一般是64字节,每个缓存行一次只能被一个CPU核访问,如果一个缓存行被多个CPU核访问,就会造成竞争,导致某个核必须等其他核处理完了才能继续处理,影响性能。
去除伪共享就是确保CPU核访问某个缓存行时不会出现争用。
预分配缓存对象,通过更新缓存里对象的属性而不是删除对象来减少垃圾回收。
数据在缓存中不是以独立的项来存储的,不是单独的变量或指针。
缓存是由缓存行组成的,通常是64字节,(32位计算机就是32字节)。
它有效地引用主内存中的一块地址。一个Java的long类型是8字节,因此在一个缓存行中可以存8个long类型的变量。
免费缓存存在弊端,可能会将完全不相关的数据同时缓存,导致缓存命中失效,拖慢性能。
通过增加补全来确保Ring buffer的序列号不会和其他东西同时存在于一个缓存行中。
ringBuffer的内存屏障
RingBuffer是核心,Barrier是连接点。
每一个消费者(EventHandler)可能都在处理不同sequence的数据。
waitFor用来请求下一个要处理的sequence。
下面的例子是10个线程并发地往disruptor里面生产事件:
- package com.mimaxueyuan.disruptor.demo1;
-
- import java.util.concurrent.CyclicBarrier;
- import java.util.concurrent.ExecutorService;
- import java.util.concurrent.Executors;
- import java.util.concurrent.ThreadFactory;
-
- import com.lmax.disruptor.BlockingWaitStrategy;
- import com.lmax.disruptor.RingBuffer;
- import com.lmax.disruptor.dsl.Disruptor;
- import com.lmax.disruptor.dsl.ProducerType;
-
-
- public class LongEventMain3 {
-
- @SuppressWarnings("unchecked")
- public static void main(String[] args) throws InterruptedException {
- // 初始化线程池-用户执行Consumer
- //Executor threadFactory = Executors.newCachedThreadPool();
- ThreadFactory threadFactory = Executors.defaultThreadFactory();
-
- // 初始化EventFactory
- LongEventFactory factory = new LongEventFactory();
-
- // 初始化RingBuffer的大小,必须是2的指数
- int bufferSize = 1024;
-
- // 初始化Disruptor
- //默认配置
- //Disruptor<LongEvent> disruptor = new Disruptor<LongEvent>(factory, bufferSize, threadFactory);
- //多线程配置
- //Disruptor<LongEvent> disruptor = new Disruptor<LongEvent>(factory, bufferSize, threadFactory,ProducerType.MULTI,new BlockingWaitStrategy());
- //单线程配置
- Disruptor<LongEvent> disruptor = new Disruptor<LongEvent>(factory, bufferSize, threadFactory,ProducerType.SINGLE,new BlockingWaitStrategy());
-
- // 指定事件处理器
- disruptor.handleEventsWith(new LongEventHandler());
-
- // 开启Disruptor,开启所有线程
- disruptor.start();
-
- // 获取RingBuffer
- RingBuffer<LongEvent> ringBuffer = disruptor.getRingBuffer();
-
- //采用固定模式向RingBuffer中添加事件
- final LongEventProducer producer = new LongEventProducer(ringBuffer);
-
- //10线程并发下的Disruptor
- final CyclicBarrier cb = new CyclicBarrier(10);
- ExecutorService executor1 = Executors.newCachedThreadPool();
- for (long i = 0; i<10; i++) {
- final long vv = i;
- executor1.submit(new Runnable() {
- @Override
- public void run() {
- try {
- System.out.println(vv+"is ready..");
- cb.await();
- producer.onData(vv);
- }catch(Exception e) {
- e.printStackTrace();
- }
- }
- });
- }
-
- //disruptor.shutdown();
- }
-
- }
下面是运行的结果:
-
- 0is ready..
- 1is ready..
- 2is ready..
- 3is ready..
- 4is ready..
- 5is ready..
- 6is ready..
- 8is ready..
- 7is ready..
- 9is ready..
- [pool-2-thread-4] LongEventProducer product -> LongEvent [value=3]
- [pool-2-thread-9] LongEventProducer product -> LongEvent [value=8]
- [pool-2-thread-2] LongEventProducer product -> LongEvent [value=1]
- [pool-2-thread-8] LongEventProducer product -> LongEvent [value=3]
- [pool-2-thread-5] LongEventProducer product -> LongEvent [value=4]
- [pool-2-thread-3] LongEventProducer product -> LongEvent [value=2]
- [pool-1-thread-1]LongEventHandler consum -> LongEvent [value=3]
- [pool-1-thread-1]LongEventHandler consum -> LongEvent [value=8]
- [pool-2-thread-6] LongEventProducer product -> LongEvent [value=5]
- [pool-2-thread-1] LongEventProducer product -> LongEvent [value=0]
- [pool-2-thread-7] LongEventProducer product -> LongEvent [value=6]
- [pool-2-thread-10] LongEventProducer product -> LongEvent [value=9]
- [pool-1-thread-1]LongEventHandler consum -> LongEvent [value=1]
- [pool-1-thread-1]LongEventHandler consum -> LongEvent [value=2]
- [pool-1-thread-1]LongEventHandler consum -> LongEvent [value=4]
- [pool-1-thread-1]LongEventHandler consum -> LongEvent [value=6]
- [pool-1-thread-1]LongEventHandler consum -> LongEvent [value=5]
- [pool-1-thread-1]LongEventHandler consum -> LongEvent [value=0]
- [pool-1-thread-1]LongEventHandler consum -> LongEvent [value=9]
-
- Process finished with exit code -1
从上面可以看出,在10个事件都成功地制造出来事件之后,10个线程的生产者会同时往disruptor里面扔入事件。
然后disruptor会单线程地去处理事件。
下面讲disruptor在多线程并行消费的时候,就是有两个消费者(两个handler)的时候,如何自定义处理每个handler中的异常事件。
下面这个代码产生了两个handler。并且自定义了两个EventExceptionHandler处理类去自定义处理每个handler中的异常。
- package com.mimaxueyuan.disruptor.demo3;
-
- import java.util.concurrent.ExecutorService;
- import java.util.concurrent.Executors;
- import java.util.concurrent.ThreadFactory;
-
- import com.lmax.disruptor.RingBuffer;
- import com.lmax.disruptor.dsl.Disruptor;
-
-
- public class UserEventMain1 {
-
- public static long startTime;
-
- @SuppressWarnings("unchecked")
- public static void main(String[] args) throws InterruptedException {
- ThreadFactory threadFactory = Executors.defaultThreadFactory();
- UserEventFactory factory = new UserEventFactory();
- int bufferSize = 1024;
- Disruptor<UserEvent> disruptor = new Disruptor<UserEvent>(factory, bufferSize, threadFactory);
-
- UserEventHandler1 userEventHandler1 = new UserEventHandler1();
- UserEventHandler2 userEventHandler2 = new UserEventHandler2();
-
- //指定两个消费者(并行)
- disruptor.handleEventsWith(userEventHandler1);
- disruptor.handleEventsWith(userEventHandler2);
-
- //设置默认的ExceptionHandler
- disruptor.setDefaultExceptionHandler(new DefaultUserEventExceptionHandler());
- //为userEventHandler1指定异常处理类为UserEventExceptionHandler1
- disruptor.handleExceptionsFor(userEventHandler1).with(new UserEventExceptionHandler1());
- //为userEventHandler2指定异常处理类为UserEventExceptionHandler2
- disruptor.handleExceptionsFor(userEventHandler2).with(new UserEventExceptionHandler2());
-
- disruptor.start();
-
- RingBuffer<UserEvent> ringBuffer = disruptor.getRingBuffer();
- final UserEventProducerWithTranslator translator = new UserEventProducerWithTranslator(ringBuffer);
-
- //5线程并发下的Disruptor
- ExecutorService executor1 = Executors.newCachedThreadPool();
- startTime = System.currentTimeMillis();
- for (int i = 0; i<5; i++) {
- final int id = i;
- executor1.submit(new Runnable() {
- @Override
- public void run() {
- try {
- User user = new User();
- user.setId(id);
- user.setName("kevin"+id);
- user.setAge(id+10);
- user.setAddress("beijing"+id);
- translator.onData(user);
- }catch(Exception e) {
- e.printStackTrace();
- }
- }
- });
- }
-
- }
-
- }
ringbuffer中事件UserEvent类
- package com.mimaxueyuan.disruptor.demo3;
-
-
- public class UserEvent {
-
- private int id;
- private String name;
- private int age;
- private String address;
-
- public int getId() {
- return id;
- }
- public void setId(int id) {
- this.id = id;
- }
- public String getName() {
- return name;
- }
- public void setName(String name) {
- this.name = name;
- }
- public int getAge() {
- return age;
- }
- public void setAge(int age) {
- this.age = age;
- }
- public String getAddress() {
- return address;
- }
- public void setAddress(String address) {
- this.address = address;
- }
- @Override
- public String toString() {
- return "UserEvent [id=" + id + ", name=" + name + ", age=" + age + ", address=" + address + "]";
- }
- }
下面是其中自定义的一个异常处理类:
- package com.mimaxueyuan.disruptor.demo3;
-
- import com.lmax.disruptor.ExceptionHandler;
-
-
- public class UserEventExceptionHandler1 implements ExceptionHandler<UserEvent> {
-
- @Override
- public void handleEventException(Throwable ex, long sequence, UserEvent event) {
- System.out.println("UserEventExceptionHandler1.handleEventException->"+event+"->"+ex.getMessage());
- }
-
- @Override
- public void handleOnStartException(Throwable ex) {
- System.out.println("UserEventExceptionHandler1.handleOnStartException->"+ex.getMessage());
- }
-
- @Override
- public void handleOnShutdownException(Throwable ex) {
- System.out.println("UserEventExceptionHandler1.handleOnShutdownException->"+ex.getMessage());
- }
-
- }
下面是以自定义格式 往disruptor中放入数据的转换工具类:
- package com.mimaxueyuan.disruptor.demo3;
-
- import com.lmax.disruptor.EventTranslatorOneArg;
- import com.lmax.disruptor.RingBuffer;
-
-
- public class UserEventProducerWithTranslator {
-
- private final RingBuffer<UserEvent> ringBuffer;
-
- public UserEventProducerWithTranslator(RingBuffer<UserEvent> ringBuffer) {
- this.ringBuffer = ringBuffer;
- }
-
- /**
- * 一个参数的EventTranslator
- */
- private static final EventTranslatorOneArg<UserEvent, User> TRANSLATOR_ONE = new EventTranslatorOneArg<UserEvent, User>() {
-
- @Override
- public void translateTo(UserEvent event, long sequence, User arg0) {
- event.setId(arg0.getId());
- event.setAddress(arg0.getAddress());
- event.setAge(arg0.getAge());
- event.setName(arg0.getName());
- }
- };
-
- public void onData(User user) {
- ringBuffer.publishEvent(TRANSLATOR_ONE, user);
- }
- }
下面是运行的结果,从运行的结果中可以看出,出现异常,并没有阻碍我们继续消费任务。:
-
- 1开始1609075543066[pool-1-thread-1]UserEventHandler1 consum -> UserEvent [id=1, name=kevin1, age=11, address=beijing1],耗时 -> 16,sleep=1s
- 2开始1609075543066[pool-1-thread-2]UserEventHandler2 consum -> UserEvent [id=1, name=kevin1, age=11, address=beijing1],耗时 -> 16,sleep=2
- 1结束1609075544081[pool-1-thread-1]UserEventHandler1 consum -> UserEvent [id=1, name=kevin1, age=11, address=beijing1Handler1Handler2],耗时 -> 1031,sleep=1s
- 1开始1609075544081[pool-1-thread-1]UserEventHandler1 consum -> UserEvent [id=4, name=kevin4, age=14, address=beijing4],耗时 -> 1031,sleep=1s
- 2结束1609075545081[pool-1-thread-2]UserEventHandler2 consum -> UserEvent [id=1, name=kevin1, age=11, address=beijing1Handler1Handler2],耗时 -> 2031,sleep=2
- 2开始1609075545081[pool-1-thread-2]UserEventHandler2 consum -> UserEvent [id=4, name=kevin4, age=14, address=beijing4Handler1],耗时 -> 2031,sleep=2
- UserEventExceptionHandler2.handleEventException->UserEvent [id=4, name=kevin4, age=14, address=beijing4Handler1]->UserEventHandler2抛出异常.
- 2开始1609075545081[pool-1-thread-2]UserEventHandler2 consum -> UserEvent [id=2, name=kevin2, age=12, address=beijing2],耗时 -> 2031,sleep=2
- 1结束1609075545097[pool-1-thread-1]UserEventHandler1 consum -> UserEvent [id=4, name=kevin4, age=14, address=beijing4Handler1],耗时 -> 2047,sleep=1s
- 1开始1609075545097[pool-1-thread-1]UserEventHandler1 consum -> UserEvent [id=2, name=kevin2, age=12, address=beijing2Handler2],耗时 -> 2047,sleep=1s
- 1结束1609075546112[pool-1-thread-1]UserEventHandler1 consum -> UserEvent [id=2, name=kevin2, age=12, address=beijing2Handler2Handler1],耗时 -> 3062,sleep=1s
- 1开始1609075546112[pool-1-thread-1]UserEventHandler1 consum -> UserEvent [id=3, name=kevin3, age=13, address=beijing3],耗时 -> 3062,sleep=1s
- UserEventExceptionHandler1.handleEventException->UserEvent [id=3, name=kevin3, age=13, address=beijing3]->UserEventHandler1抛出异常.
- 1开始1609075546112[pool-1-thread-1]UserEventHandler1 consum -> UserEvent [id=0, name=kevin0, age=10, address=beijing0],耗时 -> 3062,sleep=1s
- 2结束1609075547097[pool-1-thread-2]UserEventHandler2 consum -> UserEvent [id=2, name=kevin2, age=12, address=beijing2Handler2Handler1],耗时 -> 4047,sleep=2
- 2开始1609075547097[pool-1-thread-2]UserEventHandler2 consum -> UserEvent [id=3, name=kevin3, age=13, address=beijing3],耗时 -> 4047,sleep=2
- 1结束1609075547128[pool-1-thread-1]UserEventHandler1 consum -> UserEvent [id=0, name=kevin0, age=10, address=beijing0Handler1],耗时 -> 4078,sleep=1s
- 2结束1609075549098[pool-1-thread-2]UserEventHandler2 consum -> UserEvent [id=3, name=kevin3, age=13, address=beijing3Handler2],耗时 -> 6048,sleep=2
- 2开始1609075549098[pool-1-thread-2]UserEventHandler2 consum -> UserEvent [id=0, name=kevin0, age=10, address=beijing0Handler1],耗时 -> 6048,sleep=2
- 2结束1609075551114[pool-1-thread-2]UserEventHandler2 consum -> UserEvent [id=0, name=kevin0, age=10, address=beijing0Handler1Handler2],耗时 -> 8064,sleep=2
下面讲解disruptor的并行与串行的不同模式:
- /**
- * h1
- * h2
- */
- //指定两个消费者(并行)
- disruptor.handleEventsWith(userEventHandler1);
- disruptor.handleEventsWith(userEventHandler2);
上面这段代码表示两个消费者是并行的情况,
下面是运行的结果:
由运行的结果可以看出,线程2和线程1的开始时间和结束时间,都存在同时开始,同时结束的情况,可见两个线程是并行的。
-
- 2开始1609076143907[pool-1-thread-2]UserEventHandler2 consum -> UserEvent [id=1, name=kevin1, age=11, address=beijing1],耗时 -> 1609076143907,sleep=2
- 1开始1609076143907[pool-1-thread-1]UserEventHandler1 consum -> UserEvent [id=1, name=kevin1, age=11, address=beijing1],耗时 -> 1609076143907,sleep=1s
- 1结束1609076144907[pool-1-thread-1]UserEventHandler1 consum -> UserEvent [id=1, name=kevin1, age=11, address=beijing1Handler2Handler1],耗时 -> 1609076144907,sleep=1s
- 1开始1609076144907[pool-1-thread-1]UserEventHandler1 consum -> UserEvent [id=2, name=kevin2, age=12, address=beijing2],耗时 -> 1609076144907,sleep=1s
- 2结束1609076145907[pool-1-thread-2]UserEventHandler2 consum -> UserEvent [id=1, name=kevin1, age=11, address=beijing1Handler2Handler1],耗时 -> 1609076145907,sleep=2
- 2开始1609076145907[pool-1-thread-2]UserEventHandler2 consum -> UserEvent [id=2, name=kevin2, age=12, address=beijing2Handler1],耗时 -> 1609076145907,sleep=2
- 1结束1609076145923[pool-1-thread-1]UserEventHandler1 consum -> UserEvent [id=2, name=kevin2, age=12, address=beijing2Handler1Handler2],耗时 -> 1609076145923,sleep=1s
- 1开始1609076145923[pool-1-thread-1]UserEventHandler1 consum -> UserEvent [id=3, name=kevin3, age=13, address=beijing3],耗时 -> 1609076145923,sleep=1s
- DefaultUserEventExceptionHandler.handleEventException->UserEvent [id=3, name=kevin3, age=13, address=beijing3]->UserEventHandler1抛出异常.
- 1开始1609076145923[pool-1-thread-1]UserEventHandler1 consum -> UserEvent [id=4, name=kevin4, age=14, address=beijing4],耗时 -> 1609076145923,sleep=1s
- 1结束1609076146923[pool-1-thread-1]UserEventHandler1 consum -> UserEvent [id=4, name=kevin4, age=14, address=beijing4Handler1],耗时 -> 1609076146923,sleep=1s
- 1开始1609076146923[pool-1-thread-1]UserEventHandler1 consum -> UserEvent [id=0, name=kevin0, age=10, address=beijing0],耗时 -> 1609076146923,sleep=1s
- 2结束1609076147907[pool-1-thread-2]UserEventHandler2 consum -> UserEvent [id=2, name=kevin2, age=12, address=beijing2Handler1Handler2],耗时 -> 1609076147907,sleep=2
- 2开始1609076147907[pool-1-thread-2]UserEventHandler2 consum -> UserEvent [id=3, name=kevin3, age=13, address=beijing3],耗时 -> 1609076147907,sleep=2
- 1结束1609076147923[pool-1-thread-1]UserEventHandler1 consum -> UserEvent [id=0, name=kevin0, age=10, address=beijing0Handler1],耗时 -> 1609076147923,sleep=1s
- 2结束1609076149923[pool-1-thread-2]UserEventHandler2 consum -> UserEvent [id=3, name=kevin3, age=13, address=beijing3Handler2],耗时 -> 1609076149923,sleep=2
- 2开始1609076149923[pool-1-thread-2]UserEventHandler2 consum -> UserEvent [id=4, name=kevin4, age=14, address=beijing4Handler1],耗时 -> 1609076149923,sleep=2
- DefaultUserEventExceptionHandler.handleEventException->UserEvent [id=4, name=kevin4, age=14, address=beijing4Handler1]->UserEventHandler2抛出异常.
- 2开始1609076149923[pool-1-thread-2]UserEventHandler2 consum -> UserEvent [id=0, name=kevin0, age=10, address=beijing0Handler1],耗时 -> 1609076149923,sleep=2
- 2结束1609076151939[pool-1-thread-2]UserEventHandler2 consum -> UserEvent [id=0, name=kevin0, age=10, address=beijing0Handler1Handler2],耗时 -> 1609076151939,sleep=2
下面的代码是指定两个消费者串行:
- /**
- * h1-h2
- */
- //指定两个消费者(串行)
- disruptor.handleEventsWith(userEventHandler1).handleEventsWith(userEventHandler2);
下面是运行的结果,从结果中看,线程是先执行的线程1,再执行的线程2。两个线程是串行执行的:
-
- 1开始1609077284208[pool-1-thread-1]UserEventHandler1 consum -> UserEvent [id=1, name=kevin1, age=11, address=beijing1],耗时 -> 1609077284208,sleep=1s
- 1结束1609077285208[pool-1-thread-1]UserEventHandler1 consum -> UserEvent [id=1, name=kevin1, age=11, address=beijing1Handler1],耗时 -> 1609077285208,sleep=1s
- 1开始1609077285208[pool-1-thread-1]UserEventHandler1 consum -> UserEvent [id=2, name=kevin2, age=12, address=beijing2],耗时 -> 1609077285208,sleep=1s
- 1结束1609077286224[pool-1-thread-1]UserEventHandler1 consum -> UserEvent [id=2, name=kevin2, age=12, address=beijing2Handler1],耗时 -> 1609077286224,sleep=1s
- 1开始1609077286224[pool-1-thread-1]UserEventHandler1 consum -> UserEvent [id=3, name=kevin3, age=13, address=beijing3],耗时 -> 1609077286224,sleep=1s
- 1结束1609077287239[pool-1-thread-1]UserEventHandler1 consum -> UserEvent [id=3, name=kevin3, age=13, address=beijing3Handler1],耗时 -> 1609077287239,sleep=1s
- 1开始1609077287239[pool-1-thread-1]UserEventHandler1 consum -> UserEvent [id=4, name=kevin4, age=14, address=beijing4],耗时 -> 1609077287239,sleep=1s
- 1结束1609077288239[pool-1-thread-1]UserEventHandler1 consum -> UserEvent [id=4, name=kevin4, age=14, address=beijing4Handler1],耗时 -> 1609077288239,sleep=1s
- 1开始1609077288239[pool-1-thread-1]UserEventHandler1 consum -> UserEvent [id=0, name=kevin0, age=10, address=beijing0],耗时 -> 1609077288239,sleep=1s
- 2开始1609077288239[pool-1-thread-2]UserEventHandler2 consum -> UserEvent [id=1, name=kevin1, age=11, address=beijing1Handler1],耗时 -> 1609077288239,sleep=2
- 1结束1609077289239[pool-1-thread-1]UserEventHandler1 consum -> UserEvent [id=0, name=kevin0, age=10, address=beijing0Handler1],耗时 -> 1609077289239,sleep=1s
- 2结束1609077290239[pool-1-thread-2]UserEventHandler2 consum -> UserEvent [id=1, name=kevin1, age=11, address=beijing1Handler1Handler2],耗时 -> 1609077290239,sleep=2
- 2开始1609077290239[pool-1-thread-2]UserEventHandler2 consum -> UserEvent [id=2, name=kevin2, age=12, address=beijing2Handler1],耗时 -> 1609077290239,sleep=2
- 2结束1609077292239[pool-1-thread-2]UserEventHandler2 consum -> UserEvent [id=2, name=kevin2, age=12, address=beijing2Handler1Handler2],耗时 -> 1609077292239,sleep=2
- 2开始1609077292239[pool-1-thread-2]UserEventHandler2 consum -> UserEvent [id=3, name=kevin3, age=13, address=beijing3Handler1],耗时 -> 1609077292239,sleep=2
- 2结束1609077294239[pool-1-thread-2]UserEventHandler2 consum -> UserEvent [id=3, name=kevin3, age=13, address=beijing3Handler1Handler2],耗时 -> 1609077294239,sleep=2
- 2开始1609077294239[pool-1-thread-2]UserEventHandler2 consum -> UserEvent [id=4, name=kevin4, age=14, address=beijing4Handler1],耗时 -> 1609077294239,sleep=2
- 2结束1609077296255[pool-1-thread-2]UserEventHandler2 consum -> UserEvent [id=4, name=kevin4, age=14, address=beijing4Handler1Handler2],耗时 -> 1609077296255,sleep=2
- 2开始1609077296255[pool-1-thread-2]UserEventHandler2 consum -> UserEvent [id=0, name=kevin0, age=10, address=beijing0Handler1],耗时 -> 1609077296255,sleep=2
- 2结束1609077298271[pool-1-thread-2]UserEventHandler2 consum -> UserEvent [id=0, name=kevin0, age=10, address=beijing0Handler1Handler2],耗时 -> 1609077298271,sleep=2
-
- Process finished with exit code -1
下面是四个消费者,其中的两个先并行,后面两个在前面两个消费者执行完毕的时候,再串行执行任务:
- /**
- * h1
- * -h3-h4
- * h2
- */
- //先并行再串行
- EventHandlerGroup<UserEvent> group1 = disruptor.handleEventsWith(userEventHandler2);
- EventHandlerGroup<UserEvent> group2 = disruptor.handleEventsWith(userEventHandler1);
- group1.and(group2).handleEventsWith(userEventHandler3).handleEventsWith(userEventHandler4);
下面是运行的结果:
-
- 2开始1609077487833[pool-1-thread-1]UserEventHandler2 consum -> UserEvent [id=4, name=kevin4, age=14, address=beijing4],耗时 -> 1609077487833,sleep=2
- 1开始1609077487833[pool-1-thread-2]UserEventHandler1 consum -> UserEvent [id=4, name=kevin4, age=14, address=beijing4],耗时 -> 1609077487833,sleep=1s
- 1结束1609077488833[pool-1-thread-2]UserEventHandler1 consum -> UserEvent [id=4, name=kevin4, age=14, address=beijing4Handler2Handler1],耗时 -> 1609077488833,sleep=1s
- 1开始1609077488833[pool-1-thread-2]UserEventHandler1 consum -> UserEvent [id=3, name=kevin3, age=13, address=beijing3],耗时 -> 1609077488833,sleep=1s
- 1结束1609077489849[pool-1-thread-2]UserEventHandler1 consum -> UserEvent [id=3, name=kevin3, age=13, address=beijing3Handler1],耗时 -> 1609077489864,sleep=1s
- 1开始1609077489864[pool-1-thread-2]UserEventHandler1 consum -> UserEvent [id=2, name=kevin2, age=12, address=beijing2],耗时 -> 1609077489864,sleep=1s
- 2结束1609077489864[pool-1-thread-1]UserEventHandler2 consum -> UserEvent [id=4, name=kevin4, age=14, address=beijing4Handler2Handler1],耗时 -> 1609077489864,sleep=2
- 2开始1609077489864[pool-1-thread-1]UserEventHandler2 consum -> UserEvent [id=3, name=kevin3, age=13, address=beijing3Handler1],耗时 -> 1609077489864,sleep=2
- 1结束1609077490880[pool-1-thread-2]UserEventHandler1 consum -> UserEvent [id=2, name=kevin2, age=12, address=beijing2Handler1],耗时 -> 1609077490880,sleep=1s
- 1开始1609077490880[pool-1-thread-2]UserEventHandler1 consum -> UserEvent [id=1, name=kevin1, age=11, address=beijing1],耗时 -> 1609077490880,sleep=1s
- 2结束1609077491880[pool-1-thread-1]UserEventHandler2 consum -> UserEvent [id=3, name=kevin3, age=13, address=beijing3Handler1Handler2],耗时 -> 1609077491880,sleep=2
- 1结束1609077491880[pool-1-thread-2]UserEventHandler1 consum -> UserEvent [id=1, name=kevin1, age=11, address=beijing1Handler1],耗时 -> 1609077491880,sleep=1s
- 1开始1609077491880[pool-1-thread-2]UserEventHandler1 consum -> UserEvent [id=0, name=kevin0, age=10, address=beijing0],耗时 -> 1609077491880,sleep=1s
- 2开始1609077491880[pool-1-thread-1]UserEventHandler2 consum -> UserEvent [id=2, name=kevin2, age=12, address=beijing2Handler1],耗时 -> 1609077491880,sleep=2
- 1结束1609077492895[pool-1-thread-2]UserEventHandler1 consum -> UserEvent [id=0, name=kevin0, age=10, address=beijing0Handler1],耗时 -> 1609077492895,sleep=1s
- 2结束1609077493895[pool-1-thread-1]UserEventHandler2 consum -> UserEvent [id=2, name=kevin2, age=12, address=beijing2Handler1Handler2],耗时 -> 1609077493895,sleep=2
- 2开始1609077493895[pool-1-thread-1]UserEventHandler2 consum -> UserEvent [id=1, name=kevin1, age=11, address=beijing1Handler1],耗时 -> 1609077493895,sleep=2
- 2结束1609077495911[pool-1-thread-1]UserEventHandler2 consum -> UserEvent [id=1, name=kevin1, age=11, address=beijing1Handler1Handler2],耗时 -> 1609077495911,sleep=2
- 2开始1609077495911[pool-1-thread-1]UserEventHandler2 consum -> UserEvent [id=0, name=kevin0, age=10, address=beijing0Handler1],耗时 -> 1609077495911,sleep=2
- 3开始1609077495911[pool-1-thread-3]UserEventHandler3 consum -> UserEvent [id=4, name=kevin4, age=14, address=beijing4Handler2Handler1],耗时 -> 1609077495911,sleep=3
- 2结束1609077497911[pool-1-thread-1]UserEventHandler2 consum -> UserEvent [id=0, name=kevin0, age=10, address=beijing0Handler1Handler2],耗时 -> 1609077497911,sleep=2
- 3结束1609077498911[pool-1-thread-3]UserEventHandler3 consum -> UserEvent [id=4, name=kevin4, age=14, address=beijing4Handler2Handler1Handler3],耗时 -> 1609077498911,sleep=3
- 3开始1609077498911[pool-1-thread-3]UserEventHandler3 consum -> UserEvent [id=3, name=kevin3, age=13, address=beijing3Handler1Handler2],耗时 -> 1609077498911,sleep=3
- 3结束1609077501927[pool-1-thread-3]UserEventHandler3 consum -> UserEvent [id=3, name=kevin3, age=13, address=beijing3Handler1Handler2Handler3],耗时 -> 1609077501927,sleep=3
- 3开始1609077501927[pool-1-thread-3]UserEventHandler3 consum -> UserEvent [id=2, name=kevin2, age=12, address=beijing2Handler1Handler2],耗时 -> 1609077501927,sleep=3
- 3结束1609077504927[pool-1-thread-3]UserEventHandler3 consum -> UserEvent [id=2, name=kevin2, age=12, address=beijing2Handler1Handler2Handler3],耗时 -> 1609077504927,sleep=3
- 3开始1609077504927[pool-1-thread-3]UserEventHandler3 consum -> UserEvent [id=1, name=kevin1, age=11, address=beijing1Handler1Handler2],耗时 -> 1609077504927,sleep=3
- 3结束1609077507942[pool-1-thread-3]UserEventHandler3 consum -> UserEvent [id=1, name=kevin1, age=11, address=beijing1Handler1Handler2Handler3],耗时 -> 1609077507942,sleep=3
- 3开始1609077507942[pool-1-thread-3]UserEventHandler3 consum -> UserEvent [id=0, name=kevin0, age=10, address=beijing0Handler1Handler2],耗时 -> 1609077507942,sleep=3
- 4开始1609077507942[pool-1-thread-4]UserEventHandler4 consum -> UserEvent [id=4, name=kevin4, age=14, address=beijing4Handler2Handler1Handler3],耗时 -> 1609077507942,sleep=4
- 3结束1609077510942[pool-1-thread-3]UserEventHandler3 consum -> UserEvent [id=0, name=kevin0, age=10, address=beijing0Handler1Handler2Handler3],耗时 -> 1609077510942,sleep=3
- 4结束1609077511942[pool-1-thread-4]UserEventHandler4 consum -> UserEvent [id=4, name=kevin4, age=14, address=beijing4Handler2Handler1Handler3Handler4],耗时 -> 1609077511942,sleep=4
- 4开始1609077511942[pool-1-thread-4]UserEventHandler4 consum -> UserEvent [id=3, name=kevin3, age=13, address=beijing3Handler1Handler2Handler3],耗时 -> 1609077511942,sleep=4
- 4结束1609077515942[pool-1-thread-4]UserEventHandler4 consum -> UserEvent [id=3, name=kevin3, age=13, address=beijing3Handler1Handler2Handler3Handler4],耗时 -> 1609077515942,sleep=4
- 4开始1609077515942[pool-1-thread-4]UserEventHandler4 consum -> UserEvent [id=2, name=kevin2, age=12, address=beijing2Handler1Handler2Handler3],耗时 -> 1609077515942,sleep=4
- 4结束1609077519958[pool-1-thread-4]UserEventHandler4 consum -> UserEvent [id=2, name=kevin2, age=12, address=beijing2Handler1Handler2Handler3Handler4],耗时 -> 1609077519958,sleep=4
- 4开始1609077519958[pool-1-thread-4]UserEventHandler4 consum -> UserEvent [id=1, name=kevin1, age=11, address=beijing1Handler1Handler2Handler3],耗时 -> 1609077519958,sleep=4
- 4结束1609077523974[pool-1-thread-4]UserEventHandler4 consum -> UserEvent [id=1, name=kevin1, age=11, address=beijing1Handler1Handler2Handler3Handler4],耗时 -> 1609077523974,sleep=4
- 4开始1609077523974[pool-1-thread-4]UserEventHandler4 consum -> UserEvent [id=0, name=kevin0, age=10, address=beijing0Handler1Handler2Handler3],耗时 -> 1609077523974,sleep=4
- 4结束1609077527974[pool-1-thread-4]UserEventHandler4 consum -> UserEvent [id=0, name=kevin0, age=10, address=beijing0Handler1Handler2Handler3Handler4],耗时 -> 1609077527974,sleep=4
-
- Process finished with exit code -1
下面是5个任务,1和2串行,3和4串行,并且1和2,3和4整体上是并联的,最后串联一个1
- /**
- * h1-h2
- * -h1
- * h3-h4
- */
- EventHandlerGroup<UserEvent> group1 = disruptor.handleEventsWith(userEventHandler1).handleEventsWith(userEventHandler2);
- EventHandlerGroup<UserEvent> group2 = disruptor.handleEventsWith(userEventHandler3).handleEventsWith(userEventHandler4);
- group1.and(group2).handleEventsWith(userEventHandler1);
下面是执行的结果:
-
- 1开始1609077674297[pool-1-thread-1]UserEventHandler1 consum -> UserEvent [id=0, name=kevin0, age=10, address=beijing0],耗时 -> 1609077674297,sleep=1s
- 3开始1609077674297[pool-1-thread-3]UserEventHandler3 consum -> UserEvent [id=0, name=kevin0, age=10, address=beijing0],耗时 -> 1609077674297,sleep=3
- 1结束1609077675312[pool-1-thread-1]UserEventHandler1 consum -> UserEvent [id=0, name=kevin0, age=10, address=beijing0Handler1Handler3],耗时 -> 1609077675312,sleep=1s
- 1开始1609077675312[pool-1-thread-1]UserEventHandler1 consum -> UserEvent [id=4, name=kevin4, age=14, address=beijing4],耗时 -> 1609077675312,sleep=1s
- 1结束1609077676312[pool-1-thread-1]UserEventHandler1 consum -> UserEvent [id=4, name=kevin4, age=14, address=beijing4Handler1],耗时 -> 1609077676312,sleep=1s
- 1开始1609077676312[pool-1-thread-1]UserEventHandler1 consum -> UserEvent [id=3, name=kevin3, age=13, address=beijing3],耗时 -> 1609077676312,sleep=1s
- 3结束1609077677328[pool-1-thread-3]UserEventHandler3 consum -> UserEvent [id=0, name=kevin0, age=10, address=beijing0Handler1Handler3],耗时 -> 1609077677328,sleep=3
- 3开始1609077677328[pool-1-thread-3]UserEventHandler3 consum -> UserEvent [id=4, name=kevin4, age=14, address=beijing4Handler1],耗时 -> 1609077677328,sleep=3
- 1结束1609077677328[pool-1-thread-1]UserEventHandler1 consum -> UserEvent [id=3, name=kevin3, age=13, address=beijing3Handler1],耗时 -> 1609077677328,sleep=1s
- 1开始1609077677328[pool-1-thread-1]UserEventHandler1 consum -> UserEvent [id=2, name=kevin2, age=12, address=beijing2],耗时 -> 1609077677328,sleep=1s
- 1结束1609077678344[pool-1-thread-1]UserEventHandler1 consum -> UserEvent [id=2, name=kevin2, age=12, address=beijing2Handler1],耗时 -> 1609077678344,sleep=1s
- 1开始1609077678344[pool-1-thread-1]UserEventHandler1 consum -> UserEvent [id=1, name=kevin1, age=11, address=beijing1],耗时 -> 1609077678344,sleep=1s
- 1结束1609077679344[pool-1-thread-1]UserEventHandler1 consum -> UserEvent [id=1, name=kevin1, age=11, address=beijing1Handler1],耗时 -> 1609077679344,sleep=1s
- 2开始1609077679344[pool-1-thread-2]UserEventHandler2 consum -> UserEvent [id=0, name=kevin0, age=10, address=beijing0Handler1Handler3],耗时 -> 1609077679344,sleep=2
- 3结束1609077680344[pool-1-thread-3]UserEventHandler3 consum -> UserEvent [id=4, name=kevin4, age=14, address=beijing4Handler1Handler3],耗时 -> 1609077680344,sleep=3
- 3开始1609077680344[pool-1-thread-3]UserEventHandler3 consum -> UserEvent [id=3, name=kevin3, age=13, address=beijing3Handler1],耗时 -> 1609077680344,sleep=3
- 2结束1609077681359[pool-1-thread-2]UserEventHandler2 consum -> UserEvent [id=0, name=kevin0, age=10, address=beijing0Handler1Handler3Handler2],耗时 -> 1609077681359,sleep=2
- 2开始1609077681359[pool-1-thread-2]UserEventHandler2 consum -> UserEvent [id=4, name=kevin4, age=14, address=beijing4Handler1Handler3],耗时 -> 1609077681359,sleep=2
- 3结束1609077683350[pool-1-thread-3]UserEventHandler3 consum -> UserEvent [id=3, name=kevin3, age=13, address=beijing3Handler1Handler3],耗时 -> 1609077683350,sleep=3
- 3开始1609077683350[pool-1-thread-3]UserEventHandler3 consum -> UserEvent [id=2, name=kevin2, age=12, address=beijing2Handler1],耗时 -> 1609077683350,sleep=3
- 2结束1609077683365[pool-1-thread-2]UserEventHandler2 consum -> UserEvent [id=4, name=kevin4, age=14, address=beijing4Handler1Handler3Handler2],耗时 -> 1609077683365,sleep=2
- 2开始1609077683365[pool-1-thread-2]UserEventHandler2 consum -> UserEvent [id=3, name=kevin3, age=13, address=beijing3Handler1Handler3],耗时 -> 1609077683365,sleep=2
- 2结束1609077685366[pool-1-thread-2]UserEventHandler2 consum -> UserEvent [id=3, name=kevin3, age=13, address=beijing3Handler1Handler3Handler2],耗时 -> 1609077685366,sleep=2
- 2开始1609077685366[pool-1-thread-2]UserEventHandler2 consum -> UserEvent [id=2, name=kevin2, age=12, address=beijing2Handler1Handler3],耗时 -> 1609077685366,sleep=2
- 3结束1609077686366[pool-1-thread-3]UserEventHandler3 consum -> UserEvent [id=2, name=kevin2, age=12, address=beijing2Handler1Handler3Handler2],耗时 -> 1609077686366,sleep=3
- 3开始1609077686366[pool-1-thread-3]UserEventHandler3 consum -> UserEvent [id=1, name=kevin1, age=11, address=beijing1Handler1],耗时 -> 1609077686366,sleep=3
- 2结束1609077687381[pool-1-thread-2]UserEventHandler2 consum -> UserEvent [id=2, name=kevin2, age=12, address=beijing2Handler1Handler3Handler2],耗时 -> 1609077687381,sleep=2
- 2开始1609077687381[pool-1-thread-2]UserEventHandler2 consum -> UserEvent [id=1, name=kevin1, age=11, address=beijing1Handler1Handler3],耗时 -> 1609077687381,sleep=2
- 3结束1609077689366[pool-1-thread-3]UserEventHandler3 consum -> UserEvent [id=1, name=kevin1, age=11, address=beijing1Handler1Handler3Handler2],耗时 -> 1609077689366,sleep=3
- 4开始1609077689366[pool-1-thread-4]UserEventHandler4 consum -> UserEvent [id=0, name=kevin0, age=10, address=beijing0Handler1Handler3Handler2],耗时 -> 1609077689366,sleep=4
- 2结束1609077689381[pool-1-thread-2]UserEventHandler2 consum -> UserEvent [id=1, name=kevin1, age=11, address=beijing1Handler1Handler3Handler2],耗时 -> 1609077689381,sleep=2
- 4结束1609077693366[pool-1-thread-4]UserEventHandler4 consum -> UserEvent [id=0, name=kevin0, age=10, address=beijing0Handler1Handler3Handler2Handler4],耗时 -> 1609077693366,sleep=4
- 4开始1609077693366[pool-1-thread-4]UserEventHandler4 consum -> UserEvent [id=4, name=kevin4, age=14, address=beijing4Handler1Handler3Handler2],耗时 -> 1609077693366,sleep=4
- 4结束1609077697381[pool-1-thread-4]UserEventHandler4 consum -> UserEvent [id=4, name=kevin4, age=14, address=beijing4Handler1Handler3Handler2Handler4],耗时 -> 1609077697381,sleep=4
- 4开始1609077697381[pool-1-thread-4]UserEventHandler4 consum -> UserEvent [id=3, name=kevin3, age=13, address=beijing3Handler1Handler3Handler2],耗时 -> 1609077697381,sleep=4
- 4结束1609077701397[pool-1-thread-4]UserEventHandler4 consum -> UserEvent [id=3, name=kevin3, age=13, address=beijing3Handler1Handler3Handler2Handler4],耗时 -> 1609077701397,sleep=4
- 4开始1609077701397[pool-1-thread-4]UserEventHandler4 consum -> UserEvent [id=2, name=kevin2, age=12, address=beijing2Handler1Handler3Handler2],耗时 -> 1609077701397,sleep=4
- 4结束1609077705397[pool-1-thread-4]UserEventHandler4 consum -> UserEvent [id=2, name=kevin2, age=12, address=beijing2Handler1Handler3Handler2Handler4],耗时 -> 1609077705397,sleep=4
- 4开始1609077705397[pool-1-thread-4]UserEventHandler4 consum -> UserEvent [id=1, name=kevin1, age=11, address=beijing1Handler1Handler3Handler2],耗时 -> 1609077705397,sleep=4
- 4结束1609077709412[pool-1-thread-4]UserEventHandler4 consum -> UserEvent [id=1, name=kevin1, age=11, address=beijing1Handler1Handler3Handler2Handler4],耗时 -> 1609077709412,sleep=4
- 1开始1609077709412[pool-1-thread-5]UserEventHandler1 consum -> UserEvent [id=0, name=kevin0, age=10, address=beijing0Handler1Handler3Handler2Handler4],耗时 -> 1609077709412,sleep=1s
- 1结束1609077710412[pool-1-thread-5]UserEventHandler1 consum -> UserEvent [id=0, name=kevin0, age=10, address=beijing0Handler1Handler3Handler2Handler4Handler1],耗时 -> 1609077710412,sleep=1s
- 1开始1609077710412[pool-1-thread-5]UserEventHandler1 consum -> UserEvent [id=4, name=kevin4, age=14, address=beijing4Handler1Handler3Handler2Handler4],耗时 -> 1609077710412,sleep=1s
- 1结束1609077711428[pool-1-thread-5]UserEventHandler1 consum -> UserEvent [id=4, name=kevin4, age=14, address=beijing4Handler1Handler3Handler2Handler4Handler1],耗时 -> 1609077711428,sleep=1s
- 1开始1609077711428[pool-1-thread-5]UserEventHandler1 consum -> UserEvent [id=3, name=kevin3, age=13, address=beijing3Handler1Handler3Handler2Handler4],耗时 -> 1609077711428,sleep=1s
- 1结束1609077712444[pool-1-thread-5]UserEventHandler1 consum -> UserEvent [id=3, name=kevin3, age=13, address=beijing3Handler1Handler3Handler2Handler4Handler1],耗时 -> 1609077712444,sleep=1s
- 1开始1609077712444[pool-1-thread-5]UserEventHandler1 consum -> UserEvent [id=2, name=kevin2, age=12, address=beijing2Handler1Handler3Handler2Handler4],耗时 -> 1609077712444,sleep=1s
- 1结束1609077713444[pool-1-thread-5]UserEventHandler1 consum -> UserEvent [id=2, name=kevin2, age=12, address=beijing2Handler1Handler3Handler2Handler4Handler1],耗时 -> 1609077713444,sleep=1s
- 1开始1609077713444[pool-1-thread-5]UserEventHandler1 consum -> UserEvent [id=1, name=kevin1, age=11, address=beijing1Handler1Handler3Handler2Handler4],耗时 -> 1609077713444,sleep=1s
- 1结束1609077714459[pool-1-thread-5]UserEventHandler1 consum -> UserEvent [id=1, name=kevin1, age=11, address=beijing1Handler1Handler3Handler2Handler4Handler1],耗时 -> 1609077714459,sleep=1s
-
- Process finished with exit code -1
下面是一种奇怪的串行方式:
- /**
- * h2
- * h4- -h1
- * h3
- */
- disruptor.handleEventsWith(userEventHandler4).handleEventsWith(userEventHandler2,userEventHandler3).handleEventsWith(userEventHandler1);
下面是执行的结果:
-
- 4开始1609077876344[pool-1-thread-1]UserEventHandler4 consum -> UserEvent [id=4, name=kevin4, age=14, address=beijing4],耗时 -> 1609077876344,sleep=4
- 4结束1609077880360[pool-1-thread-1]UserEventHandler4 consum -> UserEvent [id=4, name=kevin4, age=14, address=beijing4Handler4],耗时 -> 1609077880360,sleep=4
- 4开始1609077880360[pool-1-thread-1]UserEventHandler4 consum -> UserEvent [id=3, name=kevin3, age=13, address=beijing3],耗时 -> 1609077880360,sleep=4
- 4结束1609077884360[pool-1-thread-1]UserEventHandler4 consum -> UserEvent [id=3, name=kevin3, age=13, address=beijing3Handler4],耗时 -> 1609077884360,sleep=4
- 4开始1609077884360[pool-1-thread-1]UserEventHandler4 consum -> UserEvent [id=0, name=kevin0, age=10, address=beijing0],耗时 -> 1609077884360,sleep=4
- 4结束1609077888360[pool-1-thread-1]UserEventHandler4 consum -> UserEvent [id=0, name=kevin0, age=10, address=beijing0Handler4],耗时 -> 1609077888360,sleep=4
- 4开始1609077888360[pool-1-thread-1]UserEventHandler4 consum -> UserEvent [id=2, name=kevin2, age=12, address=beijing2],耗时 -> 1609077888360,sleep=4
- 4结束1609077892376[pool-1-thread-1]UserEventHandler4 consum -> UserEvent [id=2, name=kevin2, age=12, address=beijing2Handler4],耗时 -> 1609077892376,sleep=4
- 4开始1609077892376[pool-1-thread-1]UserEventHandler4 consum -> UserEvent [id=1, name=kevin1, age=11, address=beijing1],耗时 -> 1609077892376,sleep=4
- 4结束1609077896391[pool-1-thread-1]UserEventHandler4 consum -> UserEvent [id=1, name=kevin1, age=11, address=beijing1Handler4],耗时 -> 1609077896391,sleep=4
- 3开始1609077896391[pool-1-thread-3]UserEventHandler3 consum -> UserEvent [id=4, name=kevin4, age=14, address=beijing4Handler4],耗时 -> 1609077896391,sleep=3
- 2开始1609077896391[pool-1-thread-2]UserEventHandler2 consum -> UserEvent [id=4, name=kevin4, age=14, address=beijing4Handler4],耗时 -> 1609077896391,sleep=2
- 2结束1609077898391[pool-1-thread-2]UserEventHandler2 consum -> UserEvent [id=4, name=kevin4, age=14, address=beijing4Handler4Handler3Handler2],耗时 -> 1609077898391,sleep=2
- 2开始1609077898391[pool-1-thread-2]UserEventHandler2 consum -> UserEvent [id=3, name=kevin3, age=13, address=beijing3Handler4],耗时 -> 1609077898391,sleep=2
- 3结束1609077899391[pool-1-thread-3]UserEventHandler3 consum -> UserEvent [id=4, name=kevin4, age=14, address=beijing4Handler4Handler3Handler2],耗时 -> 1609077899391,sleep=3
- 3开始1609077899391[pool-1-thread-3]UserEventHandler3 consum -> UserEvent [id=3, name=kevin3, age=13, address=beijing3Handler4Handler2],耗时 -> 1609077899391,sleep=3
- 2结束1609077900407[pool-1-thread-2]UserEventHandler2 consum -> UserEvent [id=3, name=kevin3, age=13, address=beijing3Handler4Handler2Handler3],耗时 -> 1609077900407,sleep=2
- 2开始1609077900407[pool-1-thread-2]UserEventHandler2 consum -> UserEvent [id=0, name=kevin0, age=10, address=beijing0Handler4],耗时 -> 1609077900407,sleep=2
- 3结束1609077902391[pool-1-thread-3]UserEventHandler3 consum -> UserEvent [id=3, name=kevin3, age=13, address=beijing3Handler4Handler2Handler3],耗时 -> 1609077902391,sleep=3
- 3开始1609077902391[pool-1-thread-3]UserEventHandler3 consum -> UserEvent [id=0, name=kevin0, age=10, address=beijing0Handler4Handler2],耗时 -> 1609077902391,sleep=3
- 2结束1609077902407[pool-1-thread-2]UserEventHandler2 consum -> UserEvent [id=0, name=kevin0, age=10, address=beijing0Handler4Handler2Handler3],耗时 -> 1609077902407,sleep=2
- 2开始1609077902407[pool-1-thread-2]UserEventHandler2 consum -> UserEvent [id=2, name=kevin2, age=12, address=beijing2Handler4],耗时 -> 1609077902407,sleep=2
- 2结束1609077904422[pool-1-thread-2]UserEventHandler2 consum -> UserEvent [id=2, name=kevin2, age=12, address=beijing2Handler4Handler2],耗时 -> 1609077904422,sleep=2
- 2开始1609077904422[pool-1-thread-2]UserEventHandler2 consum -> UserEvent [id=1, name=kevin1, age=11, address=beijing1Handler4],耗时 -> 1609077904422,sleep=2
- 3结束1609077905407[pool-1-thread-3]UserEventHandler3 consum -> UserEvent [id=0, name=kevin0, age=10, address=beijing0Handler4Handler2Handler3],耗时 -> 1609077905407,sleep=3
- 3开始1609077905407[pool-1-thread-3]UserEventHandler3 consum -> UserEvent [id=2, name=kevin2, age=12, address=beijing2Handler4Handler2],耗时 -> 1609077905407,sleep=3
- 2结束1609077906422[pool-1-thread-2]UserEventHandler2 consum -> UserEvent [id=1, name=kevin1, age=11, address=beijing1Handler4Handler2],耗时 -> 1609077906422,sleep=2
- 3结束1609077908422[pool-1-thread-3]UserEventHandler3 consum -> UserEvent [id=2, name=kevin2, age=12, address=beijing2Handler4Handler2Handler3],耗时 -> 1609077908422,sleep=3
- 3开始1609077908422[pool-1-thread-3]UserEventHandler3 consum -> UserEvent [id=1, name=kevin1, age=11, address=beijing1Handler4Handler2],耗时 -> 1609077908422,sleep=3
- 3结束1609077911438[pool-1-thread-3]UserEventHandler3 consum -> UserEvent [id=1, name=kevin1, age=11, address=beijing1Handler4Handler2Handler3],耗时 -> 1609077911438,sleep=3
- 1开始1609077911438[pool-1-thread-4]UserEventHandler1 consum -> UserEvent [id=4, name=kevin4, age=14, address=beijing4Handler4Handler3Handler2],耗时 -> 1609077911438,sleep=1s
- 1结束1609077912438[pool-1-thread-4]UserEventHandler1 consum -> UserEvent [id=4, name=kevin4, age=14, address=beijing4Handler4Handler3Handler2Handler1],耗时 -> 1609077912438,sleep=1s
- 1开始1609077912438[pool-1-thread-4]UserEventHandler1 consum -> UserEvent [id=3, name=kevin3, age=13, address=beijing3Handler4Handler2Handler3],耗时 -> 1609077912438,sleep=1s
- 1结束1609077913438[pool-1-thread-4]UserEventHandler1 consum -> UserEvent [id=3, name=kevin3, age=13, address=beijing3Handler4Handler2Handler3Handler1],耗时 -> 1609077913438,sleep=1s
- 1开始1609077913438[pool-1-thread-4]UserEventHandler1 consum -> UserEvent [id=0, name=kevin0, age=10, address=beijing0Handler4Handler2Handler3],耗时 -> 1609077913438,sleep=1s
- 1结束1609077914454[pool-1-thread-4]UserEventHandler1 consum -> UserEvent [id=0, name=kevin0, age=10, address=beijing0Handler4Handler2Handler3Handler1],耗时 -> 1609077914454,sleep=1s
- 1开始1609077914454[pool-1-thread-4]UserEventHandler1 consum -> UserEvent [id=2, name=kevin2, age=12, address=beijing2Handler4Handler2Handler3],耗时 -> 1609077914454,sleep=1s
- 1结束1609077915469[pool-1-thread-4]UserEventHandler1 consum -> UserEvent [id=2, name=kevin2, age=12, address=beijing2Handler4Handler2Handler3Handler1],耗时 -> 1609077915469,sleep=1s
- 1开始1609077915469[pool-1-thread-4]UserEventHandler1 consum -> UserEvent [id=1, name=kevin1, age=11, address=beijing1Handler4Handler2Handler3],耗时 -> 1609077915469,sleep=1s
- 1结束1609077916485[pool-1-thread-4]UserEventHandler1 consum -> UserEvent [id=1, name=kevin1, age=11, address=beijing1Handler4Handler2Handler3Handler1],耗时 -> 1609077916485,sleep=1s
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。