public class S implements Runnable{
public S() {
}
int x=0,y=0;
synchronized void addX(){x++;}
synchronized void addY(){y++;}
void addXY(){x++;y++;}
boolean check(){return (x>y) ? true :false;}
public void run(){
///////
System.out.println(check()) ;
}
public static void main(
String args[]){
S run = new S();
Thread t1 = new Thread(run);
Thread t2 = new Thread(run);
t1.start() ;
t2.start() ;
}
}
If this method are called in which order the check will return true?
A.call addX() and addY() simultaneously for number of times in run()
B.call addY() and addX() simultaneously for number of times in run()
c.add addXY() for number of times in run()
which answer is correct?