SCJP程序员认证考试

多选题Which two CANNOT directly cause a thread to stop executing?()ACalling the yield method.BCalling the wait method on an object.CCalling the notify method on an object.DCalling the notifyAll method on an object.ECalling the start method on another Thread 

题目
多选题
Which two CANNOT directly cause a thread to stop executing?()
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.

参考答案和解析
正确答案: E,D
解析: 暂无解析
如果没有搜索结果,请直接 联系老师 获取答案。
相似问题和答案

第1题:

Which two CANNOT directly cause a thread to stop executing?()

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

正确答案:C,D

第2题:

Which statements concerning the methods notify() and notifyAll() are true?  

  • A、Instances of class Thread have a method called notify().
  • B、A call to the method notify() will wake the thread that currently owns the monitor of the object.
  • C、The method notify() is synchronized.
  • D、The method notifyAll() is defined in class Thread.
  • E、When there is more than one thread waiting to obtain the monitor of an object, there is no way to be     sure which thread will be notified by the notify() method.

正确答案:A,E

第3题:

Given that t1 is a reference to a live thread, which is true?()

A.The Thread.sleep() method can take t1 as an argument.

B.The Object.notify() method can take t1 as an argument.

C.The Thread.yield() method can take t1 as an argument.

D.The Thread.setPriority() method can take t1 as an argument.

E.The Object.notify() method arbitrarily chooses which thread to notify.


参考答案:E

第4题:

Which two can directly cause a thread to stop executing?() 

  • A、 Exiting from a synchronized block.
  • 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 setPriority method on a thread object.

正确答案:B,E

第5题:

Given:  foo and bar are public references available to many other threads, foo refers to a Thread and bar is an Object. The thread foo is currently executing bar.wait().  From another thread, what provides the most reliable way to ensure that foo will stop executing wait()?()

  • A、foo.notify();
  • B、bar.notify();
  • C、foo.notifyAll();
  • D、Thread.notify();
  • E、bar.notifyAll();
  • F、Object.notify();

正确答案:E

第6题:

Which two of statements are true?()

  • A、It is possible to synchronize static methods.
  • B、When a thread has yielded as a result of yield(), it releases its locks.
  • C、When a thread is sleeping as a result of sleep(), it releases its locks.
  • D、The Object.wait() method can be invoked only from a synchronized context.
  • E、The Thread.sleep() method can be invoked only from a synchronized context.
  • F、When the thread scheduler receives a notify() request, and notifies a thread, that thread immediately releases its lock.

正确答案:A,D

第7题:

Under which circumstances will a thread stop?()  

  • A、The method waitforId() in class MediaTracker is called.
  • B、The run() method that the thread is executing ends.
  • C、The call to the start() method of the Thread object returns.
  • D、The suspend() method is called on the Thread object.
  • E、The wait() method is called on the Thread object.

正确答案:B

第8题:

void waitForSignal() {  Object obj = new Object();  synchronized (Thread.currentThread()) {  obj.wait();  obj.notify();  }  }  Which is true?() 

  • A、 This code may throw an InterruptedException.
  • B、 This code may throw an IllegalStateException.
  • C、 This code may throw a TimeoutException after ten minutes.
  • D、 This code will not compile unless “obj.wait()” is replaced with “((Thread) obj).wait()”.
  • E、 Reversing the order of obj.wait() and obj.notify() may cause this method to complete normally.
  • F、 A call to notify() or notifyAll() from another thread may cause this method to complete normally.

正确答案:B

第9题:

Given that t1 is a reference to a live thread, which is true?()

  • A、The Thread.sleep() method can take t1 as an argument.
  • B、The Object.notify() method can take t1 as an argument.
  • C、The Thread.yield() method can take t1 as an argument.
  • D、The Thread.setPriority() method can take t1 as an argument.
  • E、The Object.notify() method arbitrarily chooses which thread to notify.

正确答案:E

第10题:

foo and bar are public references available to many other threads. foo refers to a Thread and bar is an Object. The thread foo is currently executing bar.wait(). From another thread, which statement is the most reliable way to ensue that foo will stop executing wait()? 

  • A、 foo.notify();
  • B、 bar.notify();
  • C、 foo.notifyAll();
  • D、 Thread.notify();
  • E、 bar.notiFYAll();
  • F、 Object.notify();

正确答案:E

更多相关问题