网友您好, 请在下方输入框内输入要搜索的题目:
题目内容
(请给出正确答案)
Thread类的sleep方法会抛出()异常。
A.IOException
B.InterruptedException
C.EOFException
D.SecurityException
参考答案和解析
InterruptedException
更多 “Thread类的sleep方法会抛出()异常。A.IOExceptionB.InterruptedExceptionC.EOFExceptionD.SecurityException” 相关考题
考题
在J2EE中,VetoableChangeSupport的fireVetoableChange方法会抛出的异常是()。
A.PropertyExceptionB.PropertyVetoExceptionC.VetoExceptionD.PropertyChangeException
考题
下列程序的功能是在监控台上每隔一秒钟显示一个字符串“你好!”,能够填写在程序中画线位置,使程序完整并能正确运行的语句是 public class Exam implements Runnable{ public static void main(String args[]){ Exam t=new Exam(); Thread tt=new Thread(t); tt.start(); } public void run(){ for(;;){ try{ ; }catch(e){} System.out.println("你好!"); } } }A.sleep(1) RuntimeExceptionB.t.sleep(1000) InterruptedExceptionC.Thread.sleep(1) InterruptedExceptionD.Thread.sleep(1000) InterruptedException
考题
给你如下一段代码:你需要在类中编写更多的代码,用最少的资源每隔30秒去运行DoWork()方法()
A.Thread.Sleep(30000)B.Thread.SpinWait(30000)C.Thread.QueueUserWorkItem(30000)D.Thread.SpinWait(30)
考题
GiventhatTriangleimplementsRunnable,and:Whichtwostatements,insertedindependentlyatbothlines35and41,tendtoallowboththreadstotemporarilypauseandallowtheotherthreadtoexecute?()
A.Thread.wait();B.Thread.join();C.Thread.yield();D.Thread.sleep(1);E.Thread.notify();
考题
5.classOrder2implementsRunnable{6.publicvoidrun(){7.for(intx=0;x〈4;x++){8.try{Thread.sleep(100);}catch(Exceptione){}9.System.out.print(r);10.}}11.publicstaticvoidmain(String[]args){12.Threadt=newThread(newOrder2());13.t.start();14.for(intx=0;x〈4;x++){15.//insertcodehere16.System.out.print(m);17.}}}哪一个插入到第15行,最有可能产生输出rmrmrmrm?()A.Thread.sleep(1);B.Thread.sleep(100);C.Thread.sleep(1000);D.try{Thread.sleep(100);}catch(Exceptione){}
考题
下列程序的功能是在监控台上每隔-秒钟显示-个字符串”Hello!¨,能够填写在程序中下画线位置,使程序完整并能正确运行的语句是( )。A.sleep(1000)B.t. sleep(1000) InterruptedExceptionInterruptedExceptionC.Thread. sleep(1000)D.Thread. sleep(1000) RuntimeExceptionlnterruptedException
考题
判断下列语句哪个正确()。A、在线程休眠时,sleep方法会占用处理器时间B、将方法声明为synchronized,就可以确保不会发生死锁C、不提倡使用Thread类的suspend方法,resume方法和stop方法D、以上描述都正确
考题
下面关于Java中线程的说法不正确的是()A、调用join()方法可能抛出异常InterruptedException。B、sleep()方法是Thread类的静态方法。C、调用Thread类的sleep()方法可终止一个线程对象。D、线程启动后执行的代码放在其run方法中。
考题
现有: class Thread2 implements Runnable { void run() { System.out.print("go "); } public static void main(String [] args) { Thread2 t2 = new Thread2(); Thread t = new Thread(t2); t.start(); } } 结果为:()A、 goB、 编译失败C、 代码运行,无输出结果D、 运行时异常被抛出
考题
5. class Order2 implements Runnable { 6. public void run() { 7. for(int x = 0; x 〈 4; x++) { 8. try { Thread.sleep(100); } catch (Exception e) { } 9. System.out.print("r"); 10. } } 11. public static void main(String [] args) { 12. Thread t = new Thread(new Order2()); 13. t.start(); 14. for(int x = 0; x 〈 4; x++) { 15. // insert code here 16. System.out.print("m"); 17. } } } 哪一个插入到第15行,最有可能产生输出 rmrmrmrm ?() A、Thread.sleep(1);B、Thread.sleep(100);C、Thread.sleep(1000);D、try { Thread.sleep(100); } catch (Exception e) { }
考题
单选题给你如下一段代码: 你需要在类中编写更多的代码,用最少的资源每隔30秒去运行DoWork( )方法()A
Thread.Sleep(30000)B
Thread.SpinWait(30000)C
Thread.QueueUserWorkItem(30000)D
Thread.SpinWait(30)
考题
多选题Which two of statements are true?()AIt is possible to synchronize static methods.BWhen a thread has yielded as a result of yield(), it releases its locks.CWhen a thread is sleeping as a result of sleep(), it releases its locks.DThe Object.wait() method can be invoked only from a synchronized context.EThe Thread.sleep() method can be invoked only from a synchronized context.FWhen the thread scheduler receives a notify() request, and notifies a thread, that thread immediately releases its lock.
考题
单选题判断下列语句哪个正确()。A
在线程休眠时,sleep方法会占用处理器时间B
将方法声明为synchronized,就可以确保不会发生死锁C
不提倡使用Thread类的suspend方法,resume方法和stop方法D
以上描述都正确
考题
单选题现有: 5. class Order2 implements Runnable { 6. public void run() { 7. for (int x- o; x4; x++) { 8. try{Thread.sleep(100); )catch (Exception e) { } 9. System.out.print("r"); 10. } } 11. public static void main(string [] args) { 12. Thread t=new Thread(new order2()); 13. t.start(); 14. for(int x=0; x4; x++) { 15. //insert code here 16. System.out.print("m"); 17. } } } 哪一个插入到第15行,最有可能产生输出 rmrmrmrm?()A
Thread.sleep(1);B
Thread.sleep(100);C
Thread.sleep(1000);D
try{ Thread.sleep(1); ) catch (Exception e) { }E
try{Thread.sleep(100); ) catch (Exception e) { }F
try{Thread.sleep(1000); ) catch (Exception e) { }
考题
单选题下面关于Java中线程的说法不正确的是()A
调用join()方法可能抛出异常InterruptedException。B
sleep()方法是Thread类的静态方法。C
调用Thread类的sleep()方法可终止一个线程对象。D
线程启动后执行的代码放在其run方法中。
考题
单选题在J2EE 中,VetoableChangeSupport的fireVetoableChange方法会抛出的异常是()。A
PropertyExceptionB
PropertyVetoExceptionC
VetoExceptionD
PropertyChangeException
考题
单选题class Thread2 implements Runnable { void run() { System.out.print("go "); } public static void main(String [] args) { Thread2 t2 = new Thread2(); Thread t = new Thread(t2); t.start(); } } 结果为:()A
goB
编译失败C
代码运行,无输出结果D
运行时异常被抛出
热门标签
最新试卷