Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- List<Filial> filialsByCity = new CopyOnWriteArrayList<>();
- ExecutorService executorService = Executors.newFixedThreadPool(Location.SIBERIAN_DISTRICT.size());
- List<Future> futures = new ArrayList<>();
- for (String city : Location.SIBERIAN_DISTRICT) {
- Future future = executorService.submit(new Thread(() -> {
- Filial filial = twoGisWorkerService.getFilialByCity(fieldOfActivity, city);
- if (filial.getRating() > 0) {
- filialsByCity.add(filial);
- }
- }));
- futures.add(future);
- }
- for (Future f : futures) {
- try {
- f.get();
- } catch (InterruptedException e) {
- e.printStackTrace();
- } catch (ExecutionException e) {
- e.printStackTrace();
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement