Given the code fragment:
public class FileThread implements Runnable {
String fName;
public FileThread(String fName) { this.fName = fName; }
public void run () System.out.println(fName);}
public static void main (String[] args) throws IOException, InterruptedException {
ExecutorService executor = Executors.newCachedThreadPool();
Stream<Path> listOfFiles = Files.walk(Paths.get("Java Projects")); listOfFiles.forEach(line -> { executor.execute(new FileThread(line.getFileName().toString())); // line n1
});
executor.shutdown();
executor.awaitTermination(5, TimeUnit.DAYS); // line n2
}
}
The Java Projects directory exists and contains a list of files.
What is the result?
Destroyer
Highly Voted 4 years, 7 months agoasdfjhfgjuaDCV
Most Recent 4 months, 3 weeks agosteefaand
5 months, 3 weeks agoM_Jawad
4 years, 6 months ago