Can anyone help me in this part ?
package com.codegym.task.task16.task1616;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
/*
Counting seconds
Requirements:
1. The Stopwatch class's run method must have a loop.
2. The run method should call Thread.sleep(1000).
3. The run method should increment the field seconds every 1 second.
4. After the Stopwatch thread is interrupted, the run method must display the number of seconds.
5. There must be only one run method in the Stopwatch class.
*/
public class Solution {
public static void main(String[] args) throws IOException {
BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
// Create and run thread
Stopwatch stopwatch = new Stopwatch();
stopwatch.start();
// Read a string
try{
stopwatch.join();
}catch(Exception ex){
}
reader.readLine();
stopwatch.interrupt();
// Close streams
reader.close();
}
public static class Stopwatch extends Thread {
private int seconds;
Thread currentThr = Thread.currentThread();
public void run() {
while(!currentThr.isInterrupted()){
seconds += 1;
/*try {
//Thread.sleep(1000);
//write your code here
} catch (InterruptedException e) {
System.out.println(seconds);
}*/
}
System.out.println(this.seconds);
}
}
}