Visibility of final fields not set in constructor

51 Views Asked by At

I've seen a class do something like this

class Foo {
private final Set<Bar> set = Collections.synchronizedSet(new HashSet<>));

     public void add(Bar b) {
          set.add(b);
     }   

}

However, the final set is not initialized in the constructor. Is it still visible to other threads?

0

There are 0 best solutions below