publicclassTestFive{privateintx;publicvoidfoo(){intcurrent=x;x=current+1;}publicvoidgo(){for(inti=0;i<5;i++){newThread(){publicvoidrun(){foo();System.out.print(x+,);}}.start();}}}Whichtwochanges,takentogether,wouldguaranteetheoutput:1,2,3,4,5,?()A.Movethe

题目

publicclassTestFive{privateintx;publicvoidfoo(){intcurrent=x;x=current+1;}publicvoidgo(){for(inti=0;i<5;i++){newThread(){publicvoidrun(){foo();System.out.print(x+,);}}.start();}}}Whichtwochanges,takentogether,wouldguaranteetheoutput:1,2,3,4,5,?()

A.Movetheline12printstatementintothefoo()method.

B.Changeline7topublicsynchronizedvoidgo(){.

C.Changethevariabledeclarationonline3toprivatevolatileintx;.

D.Wrapthecodeinsidethefoo()methodwithasynchronized(this)block.

E.Wraptheforloopcodeinsidethego()methodwithasynchronizedblocksynchronized(this){//forloopcodehere}.


相似考题
更多“publicclassTestFive{privateintx;publicvoidfoo(){intcurrent=x;x=current+1;}publicvoidgo(){f ”相关问题
  • 第1题:

    若f(-x)=f(x),且在(0,+∞)内f′(x)>0,f″(x)<0,则f(x)在(-∞,0)内( )。

    A.f′(x)<0,f″(x)<0
    B.f′(x)<0,f″(x)>0
    C.f′(x)>0,f″(x)<0
    D.f′(x)>0,f″(x)>0

    答案:A
    解析:
    已知在给出的(0,+∞)内,f′(x)>0,f″(x)<0,故在(0,+∞)上f(x)单调递增,且图形是凸的,再根据已知条件f(-x)=f(x)可知f(x)是偶函数,利用图形的对称性可得出f(x)在(-∞,0)是单调递减且也是凸的。故应该选择A。

  • 第2题:

    若f(x)=-f(-x),在(0,+∞)内f′(x)>0,f″(x)>0,则在(-∞,0)内( )《》( )

    A.f′(x)<f″(x)<0
    B.f′(x)<f″(x)>0
    C.f′(x)>f″(x)<0
    D.f′(x)>f″(x)>0

    答案:C
    解析:

  • 第3题:

    下列关于整除的命题中,正确的是______。

    A.若f(x)|g(x)+h(x),则f(x)|g(x)或f(x)|h(x)

    B.若f(x)|g(x)+h(x),且f(x)|g(x),则f(x)|h(x)

    C.若f(x)|g(x)h(x),则f(x)|g(x)或f(x)|h(x)

    D.若f(x)|g(x)h(x),且f(x)不整除g(x),则f(x)|h(x)


    球面是旋转曲面

  • 第4题:

    若f(-x)=f(x),且在(0,+∞)内f′(x)>0,f″(x)<0,则f(x)在(-∞,0)内( )。《》( )

    A.f′(x)<0,f″(x)<0
    B.f′(x)<0,f″(x)>0
    C.f′(x)>0,f″(x)<0
    D.f′(x)>0,f″(x)>0

    答案:A
    解析:
    已知在给出的(0,+∞)内,f′(x)>0,f″(x)<0,故在(0,+∞)上f(x)单调递增,且图形是凸的,再根据已知条件f(-x)=f(x)可知f(x)是偶函数,利用图形的对称性可得出f(x)在(-∞,0)是单调递减且也是凸的。故应该选择A。

  • 第5题:

    若f(x)、F(x)分别为随机变量X的密度函数、分布函数,则( )。

    A.F(x)=f(x)
    B.F(x)≥f(x)
    C.F(x)≤f(x)
    D.f(x)=-F'(x)

    答案:D
    解析: