Home > Back-end >  Threading issues
Threading issues

Time:11-17

GiventhefollowingJavaclass:
 
Public class Thready implements Runnable {
Int x=1;
Int y=1;

Public void the run () {
If (x==2) x=0;
The else incX ();
If (y==2) y=0;
The 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 of x and y are not possible after both threads have run to completion?
A) x=0, y=3
B)=2 x, y=2
C)=3 x, y=0
D) x=0, y=2
E) x=0, y=0
  • Related