Skip to content

Commit 459e94e

Browse files
committed
Rename methods and use only 10 "users"
1 parent 59056fe commit 459e94e

File tree

2 files changed

+7
-6
lines changed

2 files changed

+7
-6
lines changed

reactive-programming/src/main/java/com/example/Application.java

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,14 +8,15 @@ public class Application {
88
public static void main(String[] args) {
99
ExecutorService threadPool = Executors.newFixedThreadPool(2);
1010

11-
for (int u = 1; u <= 100; u++) {
11+
for (int u = 1; u <= 10; u++) {
1212
var user = "User " + u;
13+
System.out.println("Subscribing to flux " + u);
1314
threadPool.submit(() -> {
14-
Service.getNumberFlux()
15-
.map(i -> user + ": " + i)
15+
Service.getFlux()
16+
.map(i -> user + " - " + i)
1617
.subscribe(System.out::println);
1718
});
1819
}
19-
2020
}
21+
2122
}

reactive-programming/src/main/java/com/example/Service.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77

88
public class Service {
99

10-
public static IntStream getNumberStream() {
10+
public static IntStream getStream() {
1111
return IntStream.generate(() -> {
1212
try {
1313
Thread.sleep(1000);
@@ -17,7 +17,7 @@ public static IntStream getNumberStream() {
1717
});
1818
}
1919

20-
public static Flux<Integer> getNumberFlux() {
20+
public static Flux<Integer> getFlux() {
2121
return Flux.interval(Duration.ofSeconds(1))
2222
.map(l -> (int) (Math.random() * 10));
2323
}

0 commit comments

Comments
 (0)