Implementing Executor Service in Java
When you want to get the data from the various services and make the service calls concurrently.
ExecutorService executors = Executors.newFixedThreadPool(2); //creats the thread pool of size 2
//Using method reference
Callable<Map<Integer, String>> service1cal= service1::getData;
//Using lamda expression
Callable<List<SomeBean>> service2cal= ()-> {
service2.getData(input1);
};
service2.getData(input1);
};
Future<Map<Integer, String>> service1f= executors.submit(service1cal);
Future<List<SomeBean>> service2f= executors.submit(service2cal);
Map<Integer, String> service1datamap=service1f.get(); //its a blocking statement ,it will make the main thread to wait until its ex
List<SomeBean> service2list=service2f.get();
executors.shutdown();
Sun pool domes provide another great way to use the sun's energy as a heating source for your swimming pool. Typically constructed from vinyl and aluminum, sun pool domes provide a complete enclosure for your swimming pool, preventing heat loss and also helping to keep your pool clean. Pool selber bauen
ReplyDeletezx
ReplyDeleteFascinating information I haven’t been website design studios experienced such information in quite a long time.
ReplyDeleteWoh I love your blog posts, saved to my bookmarks ! . visit the site
ReplyDeleteDazzling visual displays can be seen as the LED and fiber optic lights shift in color and set the mood for a romantic late-night swim or a bustling backyard bash. Swimmingpool
ReplyDeleteYour website is terribly informative and your articles are wonderful.
ReplyDeleteapp development studio