Use Lambda to create Thread - Java Lambda Stream

Java examples for Lambda Stream:Lambda

Description

Use Lambda to create Thread

Demo Code



public class Simple1 {
  public static void main(String[] args) {
    // no args->no param
    // ()->show()
    Thread t = new Thread(() -> show());
    t.start();/* w ww  . ja  v a2 s.com*/

    // You can convert it to
    Thread t1 = new Thread(Simple1::show);
    t1.start();

  }

  public static void show() {
    System.out.println("Hello");
  }
}

Related Tutorials