Online Java Compiler By
JavaTpoint.com
import java.util.Date; import java.util.concurrent.Executors; import java.util.concurrent.ThreadFactory; public class ExecutordefaultThreadFactoryExample2 { public static void main(String[] args) { ThreadFactory thrdfctry = Executors.defaultThreadFactory(); for(int i=0 ; i<=5 ; i++){ Thread t = thrdfctry.newThread(new Mythrd2()); t.start(); } } } class Mythrd2 implements Runnable { @Override public void run() { System.out.println("Running thread concurrently ::" + new Date()); } }
Output