...
This code does not violate CON40CON06-J. Do not synchronize on a collection view if the backing collection is accessible, because while it does synchronize on a collection view (the synchronizedList
), the backing collection is inaccessible, and therefore cannot be modified by any code.
...
This compliant solution does not use Collections.synchronizedMap()
because locking on the unsynchronized map provides sufficient thread-safety for this application. The guideline CON40CON06-J. Do not synchronize on a collection view if the backing collection is accessible provides more information about synchronizing on synchronizedMap
objects.
...