-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathBootManager.java
More file actions
45 lines (39 loc) · 1.54 KB
/
BootManager.java
File metadata and controls
45 lines (39 loc) · 1.54 KB
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
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
package core;
import utils.Logger;
import java.util.concurrent.CountDownLatch;
// Handles system boot readiness using CountDownLatch.
public class BootManager {
private final CountDownLatch bootLatch = new CountDownLatch(2);
public void initDisk() {
new Thread(() -> {
try {
Logger.log("BOOT", "Disk subsystem starting...", Logger.YELLOW);
Thread.sleep(1500);
Logger.log("BOOT", "Disk subsystem initialized. [OK]", Logger.GREEN);
} catch (InterruptedException e) {
Thread.currentThread().interrupt();
} finally {
// Count down in finally to avoid deadlock on errors.
bootLatch.countDown();
}
}, "Disk-Init-Thread").start();
}
public void initRAM() {
new Thread(() -> {
try {
Logger.log("BOOT", "RAM subsystem starting...", Logger.YELLOW);
Thread.sleep(1000);
Logger.log("BOOT", "RAM subsystem initialized. [OK]", Logger.GREEN);
} catch (InterruptedException e) {
Thread.currentThread().interrupt();
} finally {
bootLatch.countDown();
}
}, "RAM-Init-Thread").start();
}
public void awaitBootCompletion() throws InterruptedException {
Logger.log("BOOT", "Hypervisor waiting for subsystems...", Logger.CYAN);
bootLatch.await();
Logger.log("BOOT", "All subsystems ready. CloudKernel is ONLINE. [OK]", Logger.GREEN);
}
}