I read about the differences between HashMap, HashSetand HashTable. The main thing that I noticed is that I saw that HashMap/ are HashSetnot in sync as well HashTable.
However, in the code base that I saw earlier, there are several places where such a block is used:
synchronized (hashSet) {
}
How is this possible if HashSetnot synchronized? A synchronized block simply allows us to use a non-synchronous data structure, as if it were synchronized?
If they HashSetwere synchronized, we just would not need to include a synchronized () {} block?
source
share