Skip to content

Commit fcaf4d5

Browse files
Added Random variable to re-use the random instead of creating it everytime in FrontendComponent.
1 parent 8fe2ea9 commit fcaf4d5

File tree

1 file changed

+3
-1
lines changed
  • microservices-client-side-ui-composition/src/main/java/com/iluwatar/clientsideuicomposition

1 file changed

+3
-1
lines changed

microservices-client-side-ui-composition/src/main/java/com/iluwatar/clientsideuicomposition/FrontendComponent.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@
99
*/
1010
public abstract class FrontendComponent {
1111

12+
public static final Random random = new Random();
13+
1214
/**
1315
* Simulates asynchronous data fetching by introducing a random delay and
1416
* then fetching the data based on dynamic input.
@@ -19,7 +21,7 @@ public abstract class FrontendComponent {
1921
public String fetchData(Map<String, String> params) {
2022
try {
2123
// Simulate delay in fetching data (e.g., network latency)
22-
Thread.sleep(new Random().nextInt(1000));
24+
Thread.sleep(random.nextInt(1000));
2325
} catch (InterruptedException e) {
2426
Thread.currentThread().interrupt();
2527
}

0 commit comments

Comments
 (0)