Thursday, September 11, 2014

Lambda : Method Reference :: Expression

public class Greeter {
       public void greet(){
              System.out.println("Hello World!");
       }
}

public class ConcurrenceGreeter extends Greeter {

       @Override
       public void greet() {
              Thread thread = new Thread(super::greet);
              thread.start();
       }

       public static void main(String[] args) {
              Greeter greeter = new ConcurrenceGreeter();
              greeter.greet();
       }
}

Output:


Hello World!

No comments:

Post a Comment