In java 8 it is very easy to execute a runnable using Lambda.. see how it works package com.vinod.test;
package com.vinod.test;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
public class Java8RunnableExample {
private static ExecutorService executor = null;
public static void main(String[] args) {
Runnable r = () -> print();
executor = Executors.newFixedThreadPool(2);
executor.submit(r);
}
private static void print() {
System.out.println("Vinod");
}
}
Output
Vinod
0 comments:
Post a Comment