Disruptor-消费模式简介(池化)
并行模式(池化)
每个消费端有两个线程实例
disruptor.handleEventsWithWorkerPool(new A1Handler(),new A1Handler());
disruptor.handleEventsWithWorkerPool(new A2Handler(),new A2Handler());
结果示例
可以看到每次执行的线程是不一样的
++++++++++++++++++++++++++++++++++++++++++++++++
**************************
DisruptorWorker-0
**************************
1605100167571+A1Handler:10
**************************
DisruptorWorker-2
1605100167572+A2Handler:30
**************************
++++++++++++++++++++++++++++++++++++++++++++++++
**************************
DisruptorWorker-1
1605100168572+A1Handler:11
**************************
**************************
DisruptorWorker-3
1605100168573+A2Handler:31
**************************
串行模式(池化)
每个消费端有两个线程实例
disruptor.handleEventsWithWorkerPool(new A1Handler(),new A1Handler())
.then(new A2Handler(),new A2Handler());
结果示例
++++++++++++++++++++++++++++++++++++++++++++++++
**************************
DisruptorWorker-0
1605100492248+A1Handler:10
**************************
**************************
DisruptorWorker-2
1605100492249+A2Handler:30
**************************
++++++++++++++++++++++++++++++++++++++++++++++++
**************************
DisruptorWorker-1
1605100493249+A1Handler:11
**************************
**************************
DisruptorWorker-3
1605100493249+A2Handler:31
**************************