options: A i.v is guranteed always to be 0 or 1 B j.v is guranteed always to be 0 or 1 C k.v is guranteed always to be 0 or 1 D j.v will always be greater than or equal to k.v at any given time E k.v will always be greater than or equal to j.v at any given time
[B](formatted and placed between tags)[/B] [ August 18, 2005: Message edited by: Barry Gaunt ]
Hi, I've ever seen this question somewhere before. I think the question asks us what are true about using KM02 in multi-thread environment. Additonally, we must suppose that all Counter instance variables in KMO2 are instantiated properly before any methods called.
First, see the Counter class. 1) because inc() and dec() have a synchronized keyword, they are atomic and mutually exculsive. 2) int v, is a package-private variable. Although all methods of this class are synchronized, other classes in the same package as Counter can access the variable directly. If it happens, the value of v is undetermined.
Second, consider the KM02 class. 1) the same as above, i, j, and k are package-private member variables. 2) a() and b() are mutually exclusive. Counter value used in these methods are unchanged because of calling both inc() and dec() once. 3) c() is not synchronized, calling this method can intervene a() and b().
Finally, see the options. A, B. is true because i and j are only modified in the synchronized method. C. is false due to c(), which modify k, is not a synchronized method.
because of k.v is undetermined, D. and E. are false.
Ok, This is all my opinion.
SCEA5.0 (In Progress), SCBCD5.0, SCBCD1.3, SCWCD5.0, SCWCD1.4, SCJD, SCJP6.0, SCJP5.0, SCJP1.4, SCJA1.0<br />OMG Certified UML 2.0 Professional - Fundamental - Intermediate - Advanced <br />Oracle Database 10g Administrator Certified Associate