About Question enthuware.ocpjp.ii.v11.2.1081 :

Help and support on OCA OCP Java Programmer Certification Questions
1Z0-808, 1Z0-809, 1Z0-815, 1Z0-816, 1Z0-817

Moderator: admin

Post Reply
dongyingname
Posts: 18
Joined: Sat Jun 22, 2019 4:10 pm
Contact:

About Question enthuware.ocpjp.ii.v11.2.1081 :

Post by dongyingname »

For example, after acquiring the File lock, T1 tries to acquire the Printer lock. Finding the Printer lock to be already taken, it releases the lock for the File and notifies T2. At the same time, T2 tries to acquire the File lock and seeing that it is already taken it releases Printer lock and notifies T1. This process can go on and on, both the threads releasing and acquiring the locks in tandem but none of them getting both the locks at the same time. So neither of the threads is blocked but neither of the threads is able to do any real work. All they are doing is notifying each other.
I need help understanding what a Livelock is.

T1 releases File lock and T2 releases Printer lock at the exact same moment. Then they catch the thrown locks at same moment, finding that the lock each other is looking for is still in the other's hand, then they throw locks back, finding same. I'm wondering if there is any delay in T1 or T2's release action so that either of the threads holds both locks at the a moment/frame. Is this a possible scenario?

admin
Site Admin
Posts: 10065
Joined: Fri Sep 10, 2010 9:26 pm
Contact:

Re: About Question enthuware.ocpjp.ii.v11.2.1081 :

Post by admin »

I am not sure I understand your question. Yes, there could be delay. But we are talking about a particular situation.
You may go through this to understand livelock: https://www.geeksforgeeks.org/deadlock- ... -livelock/
There are several articles on livelock.
If you like our products and services, please help us by posting your review here.

Post Reply

Who is online

Users browsing this forum: No registered users and 105 guests