Like this:
package com.pong.gamedisplay;
public class TimerThread extends Thread implements Runnable {
private int secondsLeft;
public TimerThread(int seconds) {
secondsLeft = seconds;
this.start();
}
@Override
public void run() {
try {
Thread.sleep(1000);
}
catch (InterruptedException e) {}
secondsLeft--;
if (secondsLeft == 0) {
this.interrupt();
}
}
public int getSecondsLeft() {
return secondsLeft;
}
}
also is it redundant to implement Runnable in the TimerThread class if the parent class Thread already implements it? I am not getting any error no matter if I implement it to the TimerThreador not