现有:t是一个合法的Thread对象的引用,并且t的合法run()方法如下:publicvoidrun(){System.out.print(go);}及:t.start();t.start();t.run();哪一个是结果?() A.gogoB.gogogoC.go之后跟着一个异常D.gogo之后跟着一个异常

现有:t是一个合法的Thread对象的引用,并且t的合法run()方法如下:publicvoidrun(){System.out.print("go");}及:t.start();t.start();t.run();哪一个是结果?()

A.gogo

B.gogogo

C.go之后跟着一个异常

D.gogo之后跟着一个异常


相关考题:

classOrderimplementsRunnable{publicvoidrun(){try{Thread.sleep(2000);}catch(Exceptione){}System.out.print(in);}publicstaticvoidmain(String[]args){Threadt=newThread(newOrder());t.start();System.out.print(pre);try{t.join();}catch(Exceptione){}System.out.print(post);}}可产生哪两项结果?()A.inpreB.preinC.inprepostD.preinpost

t是一个合法的Thread对象的引用,并且t的合法run()方法如下:publicvoidrun(){System.out.print(go);}及:t.start();t.start();t.run();哪一个是结果?() A.goB.gogoC.gogogoD.go之后跟着一个异常

现有:classThread2implementsRunnable{voidrun(){System.out.print(go);}publicstaticvoidmain(String[]args){Thread2t2=newThread2();Threadt=newThread(t2);t.start();}}结果为:() A.goB.编译失败C.代码运行,无输出结果D.运行时异常被抛出

classOrderimplementsRunnable{publicvoidrun(){try{Thread.sleep(2000);}catch(Exceptione)System.out.print(in);publicstaticvoidmain(String[]args){Threadt=newThread(newOrder());t.start();System.out.print(pre);try{t.join();}catch(Exceptione){}System.out.print(post);可产生哪两项结果?()A.preinpostB.preinC.inpostpreD.inprepostE.prepostin

Runnabler=newRunnable(){publicvoidrun(){System.out.print(”Cat”);}};Threadt=newThread(r){publicvoidrun(){System.out.print(”Dog”);}};t.start();Whatistheresult?() A.CatB.DogC.Compilationfails.D.Thecoderunswithnooutput.E.Anexceptionisthrownatruntime.

publicclassThreads4{publicstaticvoidmain(String[]args){newThreads4().go();}publicvoidgo(){Runnabler=newRunnable(){publicvoidrun(){System.out.print(”foo”);}};Threadt=newThread(r);t.start();t.start();}}Whatistheresult?()A.Compilationfails.B.Anexceptionisthrownatruntime.C.Thecodeexecutesnormallyandprints?foo”.D.Thecodeexecutesnormally,butnothingisprinted.

publicclassThreads3implementsRunnable{publicvoidrun(){System.out.print(”running”);}publicstaticvoidmain(String[]args){Threadt=newThread(newThreads3());t.run();t.run();t.start();}}Whatistheresult?() A.Compilationfails.B.Anexceptionisthrownatruntime.C.Thecodeexecutesandprints“running”.D.Thecodeexecutesandprints“runningrunning”.E.Thecodeexecutesandprints“runningrunningrunning”.

GiventhatastaticmethoddoIt()inaclassWorkrepresentsworktobedone,whatblockofcodewillsucceedinstartinganewthreadthatwilldothework?CODEBLOCKa:Runnabler=newRunnable(){publicvoidrun(){Work.doIt();}};Threadt=newThread(r);t.start();CODEBLOCKb:Threadt=newThread(){publicvoidstart(){Work.doIt();}};t.start();CODEBLOCKc:Runnabler=newRunnable(){publicvoidrun(){Work.doIt();}};r.start();CODEBLOCKd:Threadt=newThread(newWork());t.start();CODEBLOCKe:Runnablet=newRunnable(){publicvoidrun(){Work.doIt();}};t.run();

已经声明了类“publicclassthimplementsrunnable”,下面哪条语句可以启动该类型的线程_________? A.Tht=newTh();t.start();B.newTh.start();C.Threadt=newThread(newTh());t.start();D.Tht=newTh();t.run();