-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathPrintTwoLines
48 lines (42 loc) · 1.72 KB
/
PrintTwoLines
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
46
47
48
// A simple Java program to simulate a notification system
public class Main {
public static void main(String[] args) {
// Start the notification process
System.out.println("Starting Notification System...");
// Call the method to send notification
sendNotification();
// Call the method to receive notification
receiveNotification();
// End of program
System.out.println("Notification process completed.");
}
/**
* Simulates sending a notification.
*/
public static void sendNotification() {
try {
// Simulate the process of sending a notification
System.out.println("Preparing to send notification...");
Thread.sleep(1000); // Simulating some processing delay
System.out.println("Notification sent successfully!");
} catch (InterruptedException e) {
// Handle the exception if the thread is interrupted
System.out.println("Error during notification sending: " + e.getMessage());
}
}
/**
* Simulates receiving a notification.
*/
public static void receiveNotification() {
try {
// Simulate a delay before receiving the notification
Thread.sleep(2000); // Adding 2-second gap after sending
System.out.println("Processing received notification...");
Thread.sleep(1000); // Simulating some processing delay
System.out.println("Notification received successfully!");
} catch (InterruptedException e) {
// Handle the exception if the thread is interrupted
System.out.println("Error during notification receiving: " + e.getMessage());
}
}
}