Artificial Intelligence
Please fill the required field.

Disk yandex


Disk; private final int PINNED_PERCENT; public PinnedYandexDisk(Map<String, DownloadPlan> downloadPlanMap, PinnedYandexDisk_Command historyCommands) { this.downloadPlanMap = downloadPlanMap; this.historyCommands = historyCommands; this.PINNED_PERCENT = 100; } @Override public void run() { while (downloadPlanMap.size() != 0) { for (DownloadPlan downloadPlan : downloadPlanMap.values()) { try { downloadPlan.getDownloadSemaphore().tryAcquire(); this.historyCommands.push(downloadPlan); downloadPlan.getDownloadingTask().run(); printToClient(downloadPlan.getFilePath() + " was successfully downloaded", downloadPlan.getServerURL()); downloadPlanMap.remove(downloadPlan.getServerURL()); downloadPlan.getDownloadSemaphore().dissolve(); Thread.sleep(2000); } catch (InterruptedException e) { e.printStackTrace(); } } } printToClient("Process of downloading is over", null); printToClient("Total size of downloaded files : " + downloadPlanMap.size(), null); } @SneakyThrows private void printToClient(String message, String serverURL) { if (serverURL != null) { ServerOutputBean outputBean = new ServerOutputBean(); outputBean.setServer_URL(serverURL); outputBean.setMessage(message); outputBean.setPercentage(PINNED_PERCENT); yandexDisk = new PinnedStatusYandexDisk(outputBean, "Yandex.Pinned Status Thread"); yandexDisk.start(); yandexDisk.join(); } else { historyCommands.showDownloadList(); } } }