欢迎来到易学考试网 易学考试官网
全部科目 > Java认证考试 > SCJP程序员认证考试

单项选择题

public class SyncTest { 
private int x; 
private int y; 
public synchronized void setX (int i) (x=1;) 
public synchronized void setY (int i) (y=1;) 
public synchronized 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.

点击查看答案&解析

相关考题

微信小程序免费搜题
微信扫一扫,加关注免费搜题

微信扫一扫,加关注免费搜题