Which statements concerning the methods notify() and notifyAll() are true?
第1题:
void waitForSignal() { Object obj = new Object(); synchronized (Thread.currentThread()) { obj.wait(); obj.notify(); } } Which is true?()
第2题:
Which two of statements are true?()
第3题:
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()?()
第4题:
Which two can directly cause a thread to stop executing?()
第5题:
What can cause a thread to become non-runnable?()
第6题:
Which two CANNOT directly cause a thread to stop executing? ()
第7题:
Exiting from a synchronized block.
Calling the wait method on an object.
Calling the notify method on an object.
Calling the notifyAll method on an object.
Calling the setPriority method on a thread object.
第8题:
foo.notify();
bar.notify();
foo.notifyAll();
Thread.notify();
bar.notifyAll();
第9题:
Exiting from a synchronized block.
Calling the wait method on an object.
Calling the notify method on an object.
Calling the notifyAll method on an object.
第10题:
It is possible to synchronize static methods.
When a thread has yielded as a result of yield(), it releases its locks.
When a thread is sleeping as a result of sleep(), it releases its locks.
The Object.wait() method can be invoked only from a synchronized context.
The Thread.sleep() method can be invoked only from a synchronized context.
When the thread scheduler receives a notify() request, and notifies a thread, that thread immediately releases its lock.
第11题:
foo.notify();
bar.notify();
foo.notifyAll();
Thread.notify();
bar.notifyAll();
Object.notify();
第12题:
The Thread.sleep() method can take t1 as an argument.
The Object.notify() method can take t1 as an argument.
The Thread.yield() method can take t1 as an argument.
The Thread.setPriority() method can take t1 as an argument.
The Object.notify() method arbitrarily chooses which thread to notify.
第13题:
Which two CANNOT directly cause a thread to stop executing?()
第14题:
Under which circumstances will a thread stop?()
第15题:
Given that t1 is a reference to a live thread, which is true?()
第16题:
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()?
第17题:
Which statement is true?()
第18题:
Given: foo and bar are public references available to many other threads. foo refers to a Thread and bar is anObject. The thread foo is currently executing bar.wait(). From another thread,what provides the most reliable wayto ensure that foo will stop executing wait()?
第19题:
Calling the yield method.
Calling the wait method on an object.
Calling the notify method on an object.
Calling the notifyAll method on an object.
Calling the start method on another Thread object.
第20题:
foo.notify();
bar.notify();
foo.notifyAll();
Thread.notify();
bar.notiFYAll();
Object.notify();
第21题:
Instances of class Thread have a method called notify().
A call to the method notify() will wake the thread that currently owns the monitor of the object.
The method notify() is synchronized.
The method notifyAll() is defined in class Thread.
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.
第22题:
Existing from a synchronized block.
Calling the wait method on an object.
Calling notify method on an object.
Calling read method on an InputStream object.
Calling the SetPriority method on a Thread object.
第23题:
This code may throw an InterruptedException.
This code may throw an IllegalStateException.
This code may throw a TimeoutException after ten minutes.
This code will not compile unless “obj.wait()” is replaced with “((Thread) obj).wait()”.
Reversing the order of obj.wait() and obj.notify() may cause this method to complete normally.
A call to notify() or notifyAll() from another thread may cause this method to complete normally.