多做题,通过考试没问题!

大数据考试

睦霖题库>专业技术人员继续教育公需科目>大数据考试

public class SyncTest (   private int x;   private int y;   private synchronized void setX (int i) (x=1;)   private synchronized void setY (int i) (y=1;)   public void setXY(int 1)(set X(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 separately.  
  • D、 Check() can only return true if SyncTest is changed to allow x and y to be set separately.
正确答案:B
答案解析:
进入题库查看解析

微信扫一扫手机做题