[concurrency-interest] RE: Concurrency-interest Digest, Vol 9,Issue 13

Dawid Kurzyniec dawidk at mathcs.emory.edu
Mon Oct 17 10:19:26 EDT 2005

Inanc Gumus wrote:

>Dawid, what is 'multi-field state invariant' ?? 
It means an invariant that involves multiple fields. For instance:

class Range {
   private int min, max;

this class has the invariant that min <= max. Methods setMin and setMax 
must be careful not to violate this invariant. Therefore, just making 
min and max volatile is not sufficient; with some unlucky timing, 
setMin(5) and setMax(4) could then both succeed, thus violating the 
invariant. Therefore, locking is needed. (I took the liberty of 
borrowing the example from the incoming JCP book.)


More information about the Concurrency-interest mailing list