런에이블.

Package java.lang;

public interface Runnable{ public abstract void run(); }


자바 7쓰래드 생성

public class AsyncHelloWorld{

public static class HelloWorld implements Runnable{

@Override

public void run(){

System.out.println("Hellow World!");

}

}

public static void main(String[] args){

new Thread(new HelloWorld()).start();

}

}

자바 8 쓰래드생성

public class AsycHelloWorld{

public static void main(String[] args){

new Thread(()-> {

System.out.println("Hellow World!");

}).start();

}

}


(인자목록) -> {구문}


람다식 예

(int n, String str) -> {return str+n;}

(int n, String str) -> str + n

(n,str) -> str + n

str-> str+1

( ) -> "hello, wold!"




+ Recent posts