Отсчет на гонках: 6 уровень, 10 лекция Java Core / Countdown on races: level 6, lesson 10 JavaRush

Опубликовано: 07 Январь 2026
на канале: Serhii Il
53
2

00:00 - 1
01:35 - 1.1
01:55 - 2

Отсчет на гонках: 6 уровень, 10 лекция Java Core /
Countdown on races: level 6, lesson 10 JavaRush


Задание от JavaRush
Отсчет на гонках: 6 уровень, 10 лекция Java Core

Реализуй метод run так, чтобы каждую секунду через пробел выдавался отсчет начиная с numSeconds до 1, а потом слово "Марш!"
Если нить работает 3.5 секунды или более, прерви ее методом interrupt и внутри нити выведи в консоль слово "Прервано!".
Объект класса RacingClock должен каждую секунду в цикле уменьшать значение переменной numSeconds на единицу
Метод main должен вызывать Thread.sleep(3500) и метод interrupt у объекта clock.


The task from JavaRush
Countdown on races: level 6, lesson 10 Java Core

Implement the run method so that every second, a space is counted from numSeconds to 1, and then the word "March!"
If the thread has been running for 3.5 seconds or more, interrupt it with the interrupt method and print the word "Interrupted!" To the console inside the thread.
An object of the RacingClock class must decrease the value of the numSeconds variable by one every second in a loop
The main method should call Thread.sleep (3500) and the interrupt method on the clock object.


Java Developer
Android Studio
Язык программирования Джава
Андроид Студио


Repeat after me, then delete and write the code from memory. Create a new task and write the program yourself
Повтори за мной, затем удали и напиши код по памяти. Придумай новое задание и напиши программу самостоятельно


Thank you for watching
Спасибо за просмотр