欢迎来到PP题库网 PP题库官网
logo
全部科目 > Java认证考试 > SCJP程序员认证考试

单项选择题

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 setseparately.

点击查看答案&解析

相关考题

  • 多项选择题
    WhichtwocanbeusedtocreateanewThread?()

    A. Extend java.lang.Thread and override the run method.
    B. Extend java.lang.Runnable and override the start method.
    C. Implement java.lang.thread and implement the run method.
    D. Implement java.lang.Runnable and implement the run method.
    E. Implement java.lang.Thread and implement the start method.

  • 多项选择题
    WhichtwoCANNOTdirectlycauseathreadtostopexecuting?()

    A. Calling the yield method.
    B. Calling the wait method on an object.
    C. Calling the notify method on an object.
    D. Calling the notifyAll method on an object.
    E. Calling the start method on another Thread object.

  • 单项选择题
    Whichstatementistrue?()

    A. If only one thread is blocked in the wait method of an object, and another thread executes the modify on that same object, then the first thread immediately resumes execution.
    B. If a thread is blocked in the wait method of an object, and another thread executes the notify method on the same object, it is still possible that the first thread might never resume execution.
    C. If a thread is blocked in the wait method of an object, and another thread executes the notify method on the same object, then the first thread definitely resumes execution as a direct and sole consequence of the notify call.
    D. If two threads are blocked in the wait method of one object, and another thread executes the notify method on the same object, then the first thread that executed the wait call first definitely resumes execution as a direct and sole consequence of the notify call.

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

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