I'm confused with the below question, please tell me which are correct answers.
1.Which two cannot directly cause a
thread to stop executing?
A. exiting from a synchronized block
B. calling the wait method on an object
C. calling the notify method on an object
D. calling the read method on an InputSteam object
E. calling the setPriority method on a thread object
(I pick A,C,D)
----------------------------------------------------------
2. Given:
public class SynchTest{
private int x;
private int y;
public void setX(int I){x=I;}
public void setY(int I){y=I;}
public synchronized void setXY(int I){setX(i);setY(i);}
public synchronized boolean check(){return x!=y;}
Under which conditions will check() return true when called from a different class?
A. check() can never return true
B. check() can return true when setXY is called by multiple threads
C. check() can return true when multiple threads call setX and setY deparately
D. check() can only return true if SynchTest is changed to allow x and y to be set separately
(I pick A,D)