You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I pass the folder path to method iterateRecursive(String folderPath). If in folder there is another one, it creates a new Runnable and recusively invoce same method. The problem is when root Runnable finishes its work, the other Runnable may not finish yet
public class FileService {
public void iterateRecursive(String folderPath) {
File fileFolder = new File(folderPath);
for (File file : fileFolder.listFiles()) {
if (file.isDirectory()) {
executor.submit(() -> iterateRecursive(file.getPath()));
} else {
findNotesAndSaveToFile(file.getPath());
}
}
try {
// problem is here
// so I just wait a few seconds and then shut down an executor manually
TimeUnit.SECONDS.sleep(5);
executor.shutdown();
} catch (InterruptedException e) {
e.printStackTrace();
throw new RuntimeException(e);
}
}
}
The text was updated successfully, but these errors were encountered:
I pass the folder path to method iterateRecursive(String folderPath). If in folder there is another one, it creates a new Runnable and recusively invoce same method. The problem is when root Runnable finishes its work, the other Runnable may not finish yet
The text was updated successfully, but these errors were encountered: