CompletableFuture实现异步调用

CompletableFuture.runAsync(() ->{
    System.out.println("java本身的线程调用");
});

使用Lambda 实现 Thread

public static void main(String[] args) {           new Thread(()->{                for(int i=0;i<100;i++) {
                      System.out.println("一边学习lambda");
                }
           }) .start();           
           new Thread(()-> System.out.println("一边学习奔溃"))  .start();
     }

使用Lambda 实现 Runnable

public static void main( String[] args )
    {       
        Runnable task = () -> {
            String threadName = Thread.currentThread().getName();
            System.out.println("Hello " + threadName);
        };
 
        task.run();
        Thread thread = new Thread(task);
        thread.start();
 
        System.out.println("Done!");       
    }

 

Runnable