Threads

Q1: Which of the following will not directly cause a thread to stop?

A notify()

B wait()

C InputStream access

D sleep()

ANS:A - notify()

Option A is correct. notify() - wakes up a single thread that is waiting on this object's monitor. Option B is wrong. wait() causes the current thread to wait until another thread invokes the notify() method or the notifyAll() method for this object. Option C is wrong. Methods of the InputStream class block until input data is available, the end of the stream is detected, or an exception is thrown. Blocking means that a thread may stop until certain conditions are met. Option D is wrong. sleep() - Causes the currently executing thread to sleep (temporarily cease execution) for a specified number of milliseconds. The thread does not lose ownership of any monitors.



img not found
img

For help Students Orientation
Mcqs Questions

One stop destination for examination, preparation, recruitment, and more. Specially designed online test to solve all your preparation worries. Go wherever you want to and practice whenever you want, using the online test platform.