Two problems that can occur in systems that al- low threads to wait are deadlock, in which one or more threads will wait forever for an event that cannot occur, and indefinite postponement, in which one or more threads will be delayed for some unpredictably long time. Give an example of how each of these problems can occur in multithread- ed Java programs.
What will be an ideal response?
Deadlock: If we have two threads named thread1 and thread2, deadlock might occur in the following situation: If thread1 is waiting for thread2 to complete a task, and thread2 is waiting for thread1 to complete a task, then neither thread can continue. Since both threads are in the waiting state, neither thread can be signaled to continue executing. To help prevent deadlocks, ensure locks are always taken in the same order and released in the opposite order they were taken. Indefinite Postponement: This typically occurs because threads of higher priority are scheduled before threads of lower priority.
You might also like to view...
Once an exception is thrown, when can control return to the throw point?
a. Never. b. Only after the exception is caught. c. Once the stack unwinding process is completed. d. Immediately after the exception is thrown.
The bundling of an object's data and functions together is called
A) OOP. B) encapsulation. C) data hiding. D) structuring. E) private access.
In ____ systems, deadlocks can cause critical situations.
A. batch B. interactive C. real-time D. general purpose
The ________ introduced a full-blown superscalar design with out-of-order execution.
A. Pentium B. Pentium Pro C. 386 D. 486