Given the following code, which statements concerning the objects referenced through the member variables i, j and k are true, given that any
thread may call the methods a(), b() and c() at any time?
A. i.v is guaranteed always to be 0 or 1.
B. j.v is guaranteed always to be 0 or 1.
C. k.v is guaranteed always to be 0 or 1.
D. j.v will always be greater than or equal to k.v at any give time.
E. k.v will always be greater than or equal to j.v at any give time.
ANSWERS: A, B
Why A is correct? Assume that one thread executes method's a() i.inc(), after that another thread executes method's b() i.inc().
Value of i.v will be 2, isn't it ?
Where am I mistaken ?
[ November 12, 2004: Message edited by: Barry Gaunt ]