GiventhefollowingJavaclass:
public class Thready implements Runnable{
int x=1;
int y=1;
public void run(){
if (x==2) x=0;
else incX();
if (y==2) y=0;
else y++;
}
public synchronized void incX(){
x=x+1;
}
}
If two separate threads are created for the same instance of Thready,which of the following combinations of values for the fields x and y are not possible after both threads have run to completion?
a)x=0,y=3
b)x=2,y=2
c)x=3,y=0
d)x=0,y=2
e)x=0,y=0
轉載請註明出處,本文鏈接:https://www.uj5u.com/houduan/220882.html
標籤:Java SE
