the method ( transformAll ) transform all the img for a person and their friends. can we do a small modification to these two methods so that the imgs can be transformed in parallel ? for example using ParallelStream(). the transformImige() method is just a simple method no I/O is performed. Also, can we use streams in the transformAll() method?
Q : Is the class Person a valid implementation of the monitor pattern?
public static void transformAllFriends(Person p) {
Set<Person> visited = new HashSet<>();
transformAll(p, visited);
}
public static void transformAll(Person p, Set<Person> visited) {
p.transformImige();
visited.add(p);
for (Object pi : p.friends()) {
if (visited.contains(pi)) {
continue;
}
transfrmAll(p, visited);
}
}