Commit d889e054 authored by Mohamad Bashar Desoki's avatar Mohamad Bashar Desoki

Executor Service

parent 19f2877a
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
public class ExecutorServiceFixed {
public static void main(String arg[]){
ExecutorService executorService = Executors.newFixedThreadPool(3);
for(int i=0;i<20;i++) {
executorService.execute(newRunnable(" "+i));
}
executorService.shutdown();
}
private static Runnable newRunnable(String msg){
return new Runnable() {
@Override
public void run() {
String report = Thread.currentThread().getName()+" :"+msg;
System.out.println(report);
}
};
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment