Experience lamada expression

 

 

 

Package com.inetTes01;
 / * 
requirements: start a thread, in the console output sentence: multithreaded program starts 

 * / 

Import com.liushuaishuai.MyRunnable; 

public  class lamadaDemo {
     public  static  void main (String [] args) {
         / / implementation class, need to write in advance a class myRunnbale implements Runnable interface and override run method
 //         myRunnable new new myRunnable My = ();
 //         the Thread the Thread new new T = (My);
 //         t.start (); 

        // anonymous inner classes ways to improve
 //         new new the Thread (the Runnable new new () {
 //             @Override
 //             public void RUN () {
 //                System.out.println ( "multi-threaded program starts");
 //             }
 //         }) Start ();. 

        // lamada way to improve the expression of 
        new new the Thread (() -> { 
            System.out.println ( " multithreaded programs initiated " ); 
        .}) start (); 
    } 

}

 

Guess you like

Origin www.cnblogs.com/lsswudi/p/11442594.html