原创转载请注明出处:https://www.cnblogs.com/agilestyle/p/12806947.html
A lambda expression can be understood as a concise representation of an anonymous function that can be passed around: it doesn’t have a name, but it has a list of parameters, a body, a return type, and also possibly a list of exceptions that can be thrown. That’s one big definition;
let’s break it down:
ThreadTest.java
1 package org.fool.java8; 2 3 public class ThreadTest { 4 public static void main(String[] args) { 5 new Thread(new Runnable() { 6 @Override 7 public void run() { 8 System.out.println(Thread.currentThread().getName()); 9 } 10 }).start(); 11 12 new Thread(() -> { 13 System.out.println(Thread.currentThread().getName()); 14 }).start(); 15 16 new Thread(() -> System.out.println(Thread.currentThread().getName())).start(); 17 } 18 }
Manning.Java.8.in.Action.Lambdas.Streams.and.functional-style.programming.Aug.2014
原文:https://www.cnblogs.com/agilestyle/p/12806947.html