Re: RE: Concurrency-interest Digest, Vol 9,Issue 13

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

Re: RE: Concurrency-interest Digest, Vol 9,Issue 13

Dawid Kurzyniec
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;
   setMin(int);
   setMax(int);
}

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.)

Regards,
Dawid

_______________________________________________
Concurrency-interest mailing list
[hidden email]
http://altair.cs.oswego.edu/mailman/listinfo/concurrency-interest