You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Class Enumeration defines method values which returns the values of an enumeration as a set.
This method computes this set lazily and is defined as follows:
/** The cache listing all values of this enumeration. */@transient privatevarvset:ValueSet=null@transient privatevarvsetDefined=falsedefvalues:ValueSet= {
if (!vsetDefined) {
vset =newValueSet(immutable.SortedSet.empty[Int] ++ (vmap.values map (_.id)))
vsetDefined =true
}
vset
}
I claim, that the field vsetDefined has to be declared @volatile, otherwise a thread invoking values might see vsetDefined as true, but may not see the actual value in field vset, i.e. may see vset still to be null. If vsetDefined were declared @volatile, a happens-before relation would be established between writing field vset and reading it.
The text was updated successfully, but these errors were encountered:
Class
Enumeration
defines methodvalues
which returns the values of an enumeration as a set.This method computes this set lazily and is defined as follows:
I claim, that the field
vsetDefined
has to be declared@volatile
, otherwise a thread invokingvalues
might seevsetDefined
astrue
, but may not see the actual value in fieldvset
, i.e. may seevset
still to benull
. IfvsetDefined
were declared@volatile
, a happens-before relation would be established between writing fieldvset
and reading it.The text was updated successfully, but these errors were encountered: