posted 21 years ago
Hello,
Since the yield() method moves the currently running thread to the Ready state I don't think the thread releases the lock. My understanding is that the threads X and Y are taking turns simply because they are two threads running at the same time. Since the getI() method is synchronized after one thread completes it the other thread might get hold of the C object and enter the getI() method. I think the yield() method does not affect the order of Xs and Ys, and I think that any order is possible here.
Thanks,
Alex Stojan