我有一个执行器在 singleThreadExecutor 中运行,我需要在它完成调用其他方法(saveJsonFile())之后,但只有当我的执行器完成时
我和执行人的课
ExecutorService e = Executors.newSingleThreadExecutor();
//Download HTML and Unzip Threads
typeDownloaded = "html";
DownloadUtil.downloadHtml(e, this, dns, port, offlineUuid, filePathHtmlDownload, cookies, typeDownloaded);
UnzipUtil.unZipHtml(e, this, filePathHtmlDownload, outputFolder, typeDownloaded);
e.shutdown();
saveJsonFile();
我的 UnzipUtil 类:
public class UnzipUtil {
public static void unZipHtml(Executor e, MainViewController controller, String zipFile, String outputFolder, String type) {
e.execute(new UnzipTask(controller, zipFile, outputFolder, type));
}
public static void unZipImages(Executor e, MainViewController controller, int numImg, String outputFolder, String type) throws SystemException, PortalException {
String filePath;
filePath = System.getProperty("user.home") + File.separator + "Documents" + File.separator + "TargetApp" + File.separator + "TempImageDownload.zip";
System.out.println(filePath);
e.execute(new UnzipTask(controller, filePath, outputFolder, type));
}
}