zoukankan      html  css  js  c++  java
  • Reactor系列(十八)merge合并

    #java#reactor#flux#merge#

    合并

    视频讲解: https://www.bilibili.com/video/av81746042/

    FluxMonoTestCase.java
    package com.example.reactor;
    
    import lombok.extern.slf4j.Slf4j;
    import org.junit.jupiter.api.Test;
    import reactor.core.publisher.Flux;
    
    import java.time.Duration;
    
    @Slf4j
    public class FluxMonoTestCase extends BaseTestCase {
        @Test
        public void merge() throws InterruptedException {
            Flux<Long> longFlux = Flux.interval(Duration.ofMillis(100)).take(10);
            Flux<Long> longFlux2 = Flux.interval(Duration.ofMillis(100)).take(10);
            Flux<Long> longFlux3 = Flux.merge(longFlux,longFlux2);
            longFlux3.subscribe(val ->log.info("->{}",val));
            Thread.sleep(2000);
        }
    
    }

    结果:

    5:49:21.503 [main] DEBUG reactor.util.Loggers$LoggerFactory - Using Slf4j logging framework
    15:49:21.657 [parallel-1] INFO com.example.reactor.FluxMonoTestCase - ->0
    15:49:21.657 [parallel-2] INFO com.example.reactor.FluxMonoTestCase - ->0
    15:49:21.757 [parallel-1] INFO com.example.reactor.FluxMonoTestCase - ->1
    15:49:21.757 [parallel-1] INFO com.example.reactor.FluxMonoTestCase - ->1
    15:49:21.844 [parallel-2] INFO com.example.reactor.FluxMonoTestCase - ->2
    15:49:21.845 [parallel-1] INFO com.example.reactor.FluxMonoTestCase - ->2
    15:49:21.957 [parallel-1] INFO com.example.reactor.FluxMonoTestCase - ->3
    15:49:21.957 [parallel-1] INFO com.example.reactor.FluxMonoTestCase - ->3
    15:49:22.057 [parallel-2] INFO com.example.reactor.FluxMonoTestCase - ->4
    15:49:22.057 [parallel-1] INFO com.example.reactor.FluxMonoTestCase - ->4
    15:49:22.157 [parallel-2] INFO com.example.reactor.FluxMonoTestCase - ->5
    15:49:22.157 [parallel-2] INFO com.example.reactor.FluxMonoTestCase - ->5
    15:49:22.258 [parallel-1] INFO com.example.reactor.FluxMonoTestCase - ->6
    15:49:22.258 [parallel-1] INFO com.example.reactor.FluxMonoTestCase - ->6
    15:49:22.358 [parallel-2] INFO com.example.reactor.FluxMonoTestCase - ->7
    15:49:22.358 [parallel-2] INFO com.example.reactor.FluxMonoTestCase - ->7
    15:49:22.458 [parallel-1] INFO com.example.reactor.FluxMonoTestCase - ->8
    15:49:22.458 [parallel-1] INFO com.example.reactor.FluxMonoTestCase - ->8
    15:49:22.559 [parallel-2] INFO com.example.reactor.FluxMonoTestCase - ->9
    15:49:22.559 [parallel-2] INFO com.example.reactor.FluxMonoTestCase - ->9

    公众号,坚持每天3分钟视频学习

  • 相关阅读:
    吴裕雄--天生自然python学习笔记:python 用 Tesseract 识别验证码
    吴裕雄--天生自然python学习笔记:python安装配置tesseract-ocr-setup-3.05.00dev.exe
    吴裕雄--天生自然python学习笔记:python 用 Open CV通过人脸识别进行登录
    吴裕雄--天生自然python学习笔记:python 用 Open CV抓取摄像头视频图像
    HDU4278 Faulty Odometerd
    最大流 总结
    HDU1411 欧拉四面体
    HDU3336 Count the string
    HDU1711
    HDU2203 亲和串
  • 原文地址:https://www.cnblogs.com/JavaWeiBianCheng/p/12133419.html
Copyright © 2011-2022 走看看