В обоих режимах отладки (F7 и F8) всегда падает в какие-то глубокие внутренние методы. Сама не нахожу слабое место в коде
package com.javarush.task.task16.task1613;
/*
Big Ben clock
*/
import java.time.LocalTime;
public class Solution {
public static volatile boolean isStopped = false;
public static void main(String[] args) throws InterruptedException {
Clock clock = new Clock("Лондон", 23, 59, 57);
Thread.sleep(4000);
isStopped = true;
Thread.sleep(1000);
}
public static class Clock extends Thread {
private String cityName;
private int hours;
private int minutes;
private int seconds;
LocalTime currentTime;
LocalTime actualTime;
LocalTime temp;
public Clock(String cityName, int hours, int minutes, int seconds) {
this.cityName = cityName;
this.hours = hours;
this.minutes = minutes;
this.seconds = seconds;
currentTime = LocalTime.of(hours, minutes, seconds);
start();
}
public void run() {
try {
temp = currentTime.plusSeconds(1);
actualTime = temp;
currentTime = actualTime;
while (!isStopped) {
printTime(actualTime);
}
} catch (InterruptedException e) {
}
}
private void printTime(LocalTime actualTime) throws InterruptedException {
//add your code here - добавь код тут
if (hours == 0 && minutes == 0 && seconds == 0) {
System.out.println(String.format("В г. %s сейчас полночь!", cityName));
} else {
System.out.println(String.format("В г. %s сейчас %d:%d:%d!", cityName, actualTime.getHour(), actualTime.getMinute(), actualTime.getSecond()));
}
}
}
}