Skip to content

Instantly share code, notes, and snippets.

@Yatharth0045
Last active March 26, 2019 13:13
Show Gist options
  • Save Yatharth0045/a8826d20ff04be568585d4b41f3fd917 to your computer and use it in GitHub Desktop.
Save Yatharth0045/a8826d20ff04be568585d4b41f3fd917 to your computer and use it in GitHub Desktop.
This program shows the execution of ExecutorService class.
class Threads {
public static void main(String[] args) {
ExecutorService service = Executors.newFixedThreadPool(2);
for(int count = 0; count < 10; count++){
service.execute(()->{
System.out.println("Child Thread" + Thread.currentThread().getName());
});
}
service.shutdown();
System.out.println("|Main Thread|");
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment