Java Programming :: Threads
-
Which statement is true?
-
Which two can be used to create a new Thread?
- Extend java.lang.Thread and override the run() method.
- Extend java.lang.Runnable and override the start() method.
- Implement java.lang.Thread and implement the run() method.
- Implement java.lang.Runnable and implement the run() method.
- Implement java.lang.Thread and implement the start() method.
-
Which statement is true?
-
Which two statements are true?
- Deadlock will not occur if wait()/notify() is used
- A thread will resume execution as soon as its sleep duration expires.
- Synchronization can prevent two objects from being accessed by the same thread.
- The wait() method is overloaded to accept a duration.
- The notify() method is overloaded to accept a duration.
- Both wait() and notify() must be called from a synchronized context.
-
Which statement is true?
A.
If only one thread is blocked in the wait method of an object, and another thread executes the modify on that same object, then the first thread immediately resumes execution.
|
B.
If a thread is blocked in the wait method of an object, and another thread executes the notify method on the same object, it is still possible that the first thread might never resume execution.
|
C.
If a thread is blocked in the wait method of an object, and another thread executes the notify method on the same object, then the first thread definitely resumes execution as a direct and sole consequence of the notify call.
|
D.
If two threads are blocked in the wait method of one object, and another thread executes the notify method on the same object, then the first thread that executed the wait call first definitely resumes execution as a direct and sole consequence of the notify call.
|