Is this acceptable OO Design

Is this a good OO design, assuming you want each inheriting class to be an infinite stream? Any better / more elegant way to do a similar thing?

public abstract class Base implements Runnable {

protected abstract void doSomething();

public void run() {

    while ( true ) {
        Thread.sleep(1000);
        doSomething();
    }
}
}
+5
source share
1 answer

If you want it to doSomethingrun every second, you could transfer the task to your own Runnableand schedulewith ScheduledExecutorService. Thus, you can reduce the number of threads in your program and save resources.

+11
source

All Articles