Simple-clock
Simple-clock
SimpleDateFormat;
import java.util.Date;
class Clock {
private final SimpleDateFormat formatter = new SimpleDateFormat("HH:mm:ss dd-MM-
yyyy");
@Override
public void run() {
while (true) {
try {
Thread.sleep(1000); // Simulate background logic
} catch (InterruptedException e) {
System.out.println("Updater Interrupted: " + e.getMessage());
}
}
}
}
@Override
public void run() {
while (true) {
clock.displayTime();
try {
Thread.sleep(1000); // Update every second
} catch (InterruptedException e) {
System.out.println("Display Interrupted: " + e.getMessage());
}
}
}
}
updater.setPriority(Thread.MIN_PRIORITY);
display.setPriority(Thread.MAX_PRIORITY);
updater.start();
display.start();
}
}