enthuware.ocpjp.v11.2.1423

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

Moderator: admin

Post Reply
ketank
Posts: 10
Joined: Thu Apr 15, 2021 9:02 am
Contact:

enthuware.ocpjp.v11.2.1423

Post by ketank »

Justification for the said question :

The Java exception mechanism is integrated with the Java synchronization model, so that locks are released if synchronized statements and invocations of synchronized methods complete abruptly. Note that this does not apply to java.util.concurrent.locks.Lock. These locks must be released by the programmer explicitly and the recommended pattern of usage is as follows:      Lock l = ...;      l.lock();      try {          // access the resource protected by this lock      } finally {          l.unlock();      }

What if we don't release the java.util.concurrent.locks.Lock and exception occurs in try block.


Thx.

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

Re: enthuware.ocpjp.v11.2.1423

Post by admin »

It will remain locked! It may lead to a deadlock later on.
That is why it is important to call unlock() in finally.
You might want to go through a good book before attempting mock exams.
If you like our products and services, please help us by posting your review here.

ketank
Posts: 10
Joined: Thu Apr 15, 2021 9:02 am
Contact:

Re: enthuware.ocpjp.v11.2.1423

Post by ketank »

Thanks for the inputs. I am short on time so instead of reading a book I have gone through a course. I am getting ~65-70% on mocks. I am working on weak links. Have exam scheduled for tonight.

Thx.

Post Reply

Who is online

Users browsing this forum: Bing [Bot] and 61 guests