-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMain.java
27 lines (23 loc) · 812 Bytes
/
Main.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
import java.io.IOException;
public class Main {
public static void main(String[] args) {
int numNodes = Integer.parseInt(args[0]); // Number of nodes to create
int startingPort = 8001; // Starting port number, can be adjusted as needed
for (int i = 1; i <= numNodes; i++) {
final int nodeId = i;
final int port = startingPort + nodeId - 1;
Thread thread = new Thread(() -> {
try {
runInstance(port);
} catch (IOException e) {
e.printStackTrace();
}
});
thread.start();
}
}
private static void runInstance(int port) throws IOException {
Instance instance = new Instance(port);
instance.run();
}
}