From what threading problem does the program suffer?

Given:

From what threading problem does the program suffer?

Given:

From what threading problem does the program suffer?

A.
deadlock

B.
livelock

C.
starvation

D.
race condition

Explanation:
A thread often acts in response to the action of another thread. If the other thread’s action is also a response to the action of another thread, thenlivelock may result. As with deadlock, livelocked threads are unable to make further progress. However, the threads are not blocked — they are simply too busy responding to each other to resume work. This is comparable to two people attempting to pass each other in a corridor: Alphonse moves to his left to let Gaston pass, while Gaston moves to his right to let Alphonse pass. Seeing that they are still blocking each other, Alphone moves to his right, while Gaston moves to his left. They’re still blocking each other, so…



Leave a Reply 12

Your email address will not be published. Required fields are marked *


Serg

Serg

Correct is A – dedloc.

Jav

Jav

I Think B is correct: here is an answer I found:

A thread often acts in response to the action of another thread. If the other thread’s action is also a response to the action of another thread, then livelock may result. As with deadlock, livelocked threads are unable to make further progress. However, the threads are not blocked — they are simply too busy responding to each other to resume work. This is comparable to two people attempting to pass each other in a corridor: Alphonse moves to his left to let Gaston pass, while Gaston moves to his right to let Alphonse pass. Seeing that they are still blocking each other, Alphone moves to his right, while Gaston moves to his left. They’re still blocking each other, so…

GoodLuck

GoodLuck

I’m not too sure about the answer… How is there no blocking when the 2 threads have locked their own monitor and is now looking to acquire another lock of the the other object?

mato

mato

I think its A – deadlock

Tim

Tim

I would vote for A. Two threads are not busy doing anything (livelock), and seems just waiting for each other (deadlock).

Rad

Rad

In my test it’s deadlock.

pavan

pavan

Deadlock (A)

marvin

marvin

A – deadlock
Explanation: Both Threads execute display with Counter parameter pointing to other Counter. Invoking display they acquire monitor (since methods are synchronized) and sleep (this enforces both have opportunity to get monitor). Going forward they try to invoke increment method on Counter object that is already locked.

wolfatthegate

wolfatthegate

Deadlock because locks from two different objects block each others.

wolfatthegate

wolfatthegate

tested. It is Deadlock.