Given the output shown below:
Path path1 = Paths.get("/Users/someone/foo");
Path path2 = Paths.get("/Users/someone/foo");
System.out.println(path1.toString() == path2.toString()); // outputs false
System.out.println(path1.toString().equals(path2.toString())); // outputs true
Given the following two threads, is it possible for both threads to be running in the critical section at the same time?
// Thread 1
synchronized (path1.toString()) {
// Critical section
}
// Thread 2
synchronized (path2.toString()) {
// Critical section
}