File tree Expand file tree Collapse file tree 2 files changed +7
-6
lines changed
reactive-programming/src/main/java/com/example Expand file tree Collapse file tree 2 files changed +7
-6
lines changed Original file line number Diff line number Diff line change @@ -8,14 +8,15 @@ public class Application {
8
8
public static void main (String [] args ) {
9
9
ExecutorService threadPool = Executors .newFixedThreadPool (2 );
10
10
11
- for (int u = 1 ; u <= 100 ; u ++) {
11
+ for (int u = 1 ; u <= 10 ; u ++) {
12
12
var user = "User " + u ;
13
+ System .out .println ("Subscribing to flux " + u );
13
14
threadPool .submit (() -> {
14
- Service .getNumberFlux ()
15
- .map (i -> user + ": " + i )
15
+ Service .getFlux ()
16
+ .map (i -> user + " - " + i )
16
17
.subscribe (System .out ::println );
17
18
});
18
19
}
19
-
20
20
}
21
+
21
22
}
Original file line number Diff line number Diff line change 7
7
8
8
public class Service {
9
9
10
- public static IntStream getNumberStream () {
10
+ public static IntStream getStream () {
11
11
return IntStream .generate (() -> {
12
12
try {
13
13
Thread .sleep (1000 );
@@ -17,7 +17,7 @@ public static IntStream getNumberStream() {
17
17
});
18
18
}
19
19
20
- public static Flux <Integer > getNumberFlux () {
20
+ public static Flux <Integer > getFlux () {
21
21
return Flux .interval (Duration .ofSeconds (1 ))
22
22
.map (l -> (int ) (Math .random () * 10 ));
23
23
}
You can’t perform that action at this time.
0 commit comments