Difficults Flashcards
ForkJoin
example of fibbonacci
RecursiveAction
Dont return anything, implements the compute method
it executes the compute method with solve()
RecursiveTask
l
invokeall
fgd
forkjoinpool
l
fork
yy
Always use the .compute() method in recursive task before the join method
make sure that fork() is called before the current thread begins a subtask and that join() is called after it finishes retrieving the results, in order for them to be done in parallel.
notes
The invokeAll() method takes two instances of the fork/join class and does not return a result.
The fork() method causes a new task to be submitted to the pool and is similar to the thread executor submit() method.
The join() method is called after the fork() method and causes the current thread to wait for the results of a subtask.
Unlike fork(), calling compute() within a compute() method causes the task to wait for the results of the subtask.
The fork() method should be called before the current thread performs a compute() operation, with join() called to read the results afterward.
Since compute() takes no arguments, the constructor of the class is often used to pass instructions to the task.
Files.find(Path, int, BiPredicate)
Returns a Stream of paths that traverses the directory specified, to a max depth of the int specified, filtering the stream on the BiPredicate provided
public static Stream find(Path start, int maxDepth, BiPredicate matcher, FileVisitOption… options) throws IOException
Files method
Files.walk(path)
Returns a Stream object that traverses the directory in a depth-first, lazy manner. Recorre todos los hijos del path y devuelve stream con estos
May throw IOException
Files method
Files.list(Path)
Returns a Stream containing the contents of the directory specified, only to one level, so no traversing down the rest of the structure.