package ciao_churu.generic;
import java.util.concurrent.Callable;
interface Testable {
void run();
}
@SuppressWarnings("rawtypes")
class A implements Callable
{
@Override
public Object call() throws Exception {
System.out.println("CallableStart");
return null;
}
}
public class example {
public static void test(Runnable test1) {
test1.run();
}
public static <T> T test2(Callable<T> test2) {
try
{
return test2.call();
} catch (Exception ex) {
return null;
}
}
@SuppressWarnings("unchecked")
public static void main(String args[]) {
//1번
test(()->{
System.out.println("run implments");
});
//2번
@SuppressWarnings("rawtypes")
Callable test2Runnable = new A()// A클래스는 Ruunable을 implements한 클래스
{
//익명 클래스 부분
@Override
public Object call()
{
System.out.println("run implments[Not] lamdaType");
return null;
}
};
test2(test2Runnable);
}
}
참고자료 : https://nowonbun.tistory.com/499?category=636956