Şöyle yaparız
Flux<Integer> flux = Flux.range(0, 2).map(i -> {return i;});//create a runnable with flux subscriptionRunnable r = () -> flux.subscribe(s -> {...});Thread t1 = new Thread(r, "t1");Thread t2 = new Thread(r, "t2");t1.start();t2.start();
Şöyle yaparız
Flux<Integer> flux = Flux.range(0, 2).subscribeOn(Schedulers.boundedElastic()).map(i -> {System.out.println("First Thread : " + Thread.currentThread().getName());return i;}).subscribeOn(Schedulers.single()).map(i-> {System.out.println("Second Thread : " + Thread.currentThread().getName());return i;});flux.subscribe();Thread.sleep(1000);
Hiç yorum yok:
Yorum Gönder