Meaning of lambda () -> { } in Java

Lamda expression is an anonymous function that allows you to pass methods as arguments or simply, a mechanism that helps you remove a lot of boilerplate code. They have no access modifier(private, public or protected), no return type declaration and no name.

Lets take a look at this example.

(int a, int b) -> {return a > b}

In your case, you can do something like below:

schedulerFuture = taskScheduler.schedule(new Runnable() {
     public void run() {
        // task details
}, this);

Its a Runnable with an empty run definition. The anonymous class representation of this would be:

new Runnable() {
     @Override public void run() {
          // could have done something here

For lambdas:

Left side is arguments, what you take. Enclosed in () are all the arguments this function takes

-> indicates that it's a function that takes what's on the left and passes it on to the right for processing

Right side is the body - what the lambda does. Enclosed in {} is everything this function does

After you figure that out you only need to know that that construction passes an instance of matching class (look at what's the expected argument type in the schedule() call) with it's only method doing exactly the same as the lambda expression we've just analyzed.