//For whatever things were written before were written for our learning, that through patience and through encouragement of the Scriptures we might have hope. (Romans 15:4) package com.javarush.task.task16.task1616; import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; /* СÑиÑаем ÑекÑÐ½Ð´Ñ */ public class Solution { public static void main(String[] args) throws IOException { InputStreamReader in = new InputStreamReader(System.in); BufferedReader reader = new BufferedReader(in); //create and run thread Stopwatch stopwatch = new Stopwatch(); stopwatch.start(); //read a string reader.readLine(); stopwatch.interrupt(); //close streams reader.close(); in.close(); } public static class Stopwatch extends Thread { private int seconds; public void run() { try { while (true) {//add your code here - добавÑÑе код ÑÑÑ Thread.sleep(1000); seconds++; } } catch (InterruptedException e) { System.out.println(seconds); } } } } /* СÑиÑаем ÑекÑÐ½Ð´Ñ 1. ÐапиÑи ÑеализаÑÐ¸Ñ Ð¼ÐµÑода run в ниÑи Stopwatch (ÑекÑндомеÑ). 2. Stopwatch должен поÑÑиÑаÑÑ ÐºÐ¾Ð»Ð¸ÑеÑÑво ÑекÑнд, коÑоÑое пÑоÑло Ð¾Ñ ÑÐ¾Ð·Ð´Ð°Ð½Ð¸Ñ Ð½Ð¸Ñи до ввода ÑÑÑоки. 3. ÐÑведи колиÑеÑÑво ÑекÑнд в конÑолÑ. ТÑебованиÑ: 1.âÐеÑод run клаÑÑа Stopwatch (ÑекÑндомеÑ) должен ÑодеÑжаÑÑ Ñикл. 2.âÐеÑод run должен вÑзÑваÑÑ Thread.sleep(1000). 3.âÐеÑод run должен ÑвелиÑиваÑÑ Ð·Ð½Ð°Ñение Ð¿Ð¾Ð»Ñ seconds на 1 каждÑÑ ÑекÑндÑ. 4.âÐоÑле пÑеÑÑÐ²Ð°Ð½Ð¸Ñ ÑабоÑÑ Ð½Ð¸Ñи Stopwatch (вÑзова меÑода interrupt), меÑод run должен вÑвеÑÑи колиÑеÑÑво ÑекÑнд (seconds) в конÑолÑ. 5.âРклаÑÑе Stopwatch должен бÑÑÑ ÑолÑко один меÑод run. package com.javarush.task.task16.task1616; import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; * СÑиÑаем ÑекÑÐ½Ð´Ñ * public class Solution { public static void main(String[] args) throws IOException { InputStreamReader in = new InputStreamReader(System.in); BufferedReader reader = new BufferedReader(in); //create and run thread Stopwatch stopwatch = new Stopwatch(); stopwatch.start(); //read a string reader.readLine(); stopwatch.interrupt(); //close streams reader.close(); in.close(); } public static class Stopwatch extends Thread { private int seconds; public void run() { try { //add your code here - добавÑÑе код ÑÑÑ } catch (InterruptedException e) { System.out.println(seconds); } } } } */