I would like to simplify a piece of code (see below) to a lambda expression:
Task<Void> sleeper = new Task<Void>() {
@Override
protected Void call() throws Exception {
try {
Thread.sleep(5000);
} catch (InterruptedException e) {
}
return null;
}
};
I tried to simplify it like this:
1/
Task<Void> sleeper = () ->{ Thread.sleep( 5000 ); };
2/
Worker<Void> sleeper = () ->{ Thread.sleep( 5000 ); };
Unfortunately both solution do not compile as task is not an interface and Worker has multiple non-overriding methods
is it possible to simplify it ?
thanks