import [Link].
SimpleDateFormat;
import [Link];
class Clock {
private final SimpleDateFormat formatter = new SimpleDateFormat("HH:mm:ss dd-MM-
yyyy");
public void displayTime() {
String currentTime = [Link](new Date());
[Link]("Current Time: " + currentTime);
}
}
class TimeUpdater extends Thread {
private final Clock clock;
public TimeUpdater(Clock clock) {
[Link] = clock;
}
@Override
public void run() {
while (true) {
try {
[Link](1000); // Simulate background logic
} catch (InterruptedException e) {
[Link]("Updater Interrupted: " + [Link]());
}
}
}
}
class ClockDisplay extends Thread {
private final Clock clock;
public ClockDisplay(Clock clock) {
[Link] = clock;
}
@Override
public void run() {
while (true) {
[Link]();
try {
[Link](1000); // Update every second
} catch (InterruptedException e) {
[Link]("Display Interrupted: " + [Link]());
}
}
}
}
public class SimpleClockApp {
public static void main(String[] args) {
Clock clock = new Clock();
TimeUpdater updater = new TimeUpdater(clock);
ClockDisplay display = new ClockDisplay(clock);
[Link](Thread.MIN_PRIORITY);
[Link](Thread.MAX_PRIORITY);
[Link]();
[Link]();
}
}