As you hopefully know you can use lambdas in Java 8, for example to replace anonymous methods.
An example can be seen here of Java 7 vs Java 8:
Runna
I know this is an old post, but for completeness, I wanted to include the wrapper solution posted by Flown:
private static TimerTask wrap(Runnable r) {
return new TimerTask() {
@Override
public void run() {
r.run();
}
};
}
then your call can become:
timer.schedule(wrap(this::checkDirectory), delay);