JAvaマルチスレッド-lambdaと匿名の内部クラス
960 ワード
// ,
new Thread (new Runnable() {
public void run() {
for(int i=0;i<5;i++)
{
System.out.println("me");
}
}
}).start();
// lambda , ,
new Thread (()-> {
for(int i=0;i<5;i++)
{
System.out.println("me");
}
}).start();
** :**
public class hh {
//
static class like2 implements ilike
{
public void lambda()
{
System.out.println("2");
}
}
public static void main(String[]args)
{
ilike like =new like();
like=new like2();
like.lambda();
// , ilike
like =new ilike()
{
public void lambda()
{
System.out.println("3");
}
};
like.lambda();
//lambda
like=()->{
System.out.println("4");
};
like.lambda();
}}interface ilike{void lambda();}class like implements ilike{public void lambda(){System.out.println("i like")}}