This week's giveaway is in the Spring forum.
We're giving away four copies of REST with Spring (video course) and have Eugen Paraschiv on-line!
See this thread for details.
The moose likes Developer Certification (SCJD/OCMJD) and the fly likes Deadlock question Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of REST with Spring (video course) this week in the Spring forum!
JavaRanch » Java Forums » Certification » Developer Certification (SCJD/OCMJD)
Bookmark "Deadlock question" Watch "Deadlock question" New topic

Deadlock question

Ramses Tutoli

Joined: Sep 05, 2003
Posts: 26
Right now in my code, I think deadlock can occur in LocalDataClient/RemoteDataClientImpl after a record is locked but before a record is unlocked if an exception is thrown in one of the methods. For example, take the following code in my LocalDataClient class:

if an exception is thrown in my call to db.delete(), the record never has a chance to unlock. Would it be ok to put my db.unlock() method in a finally{} clause to fix this?
Philippe Maquet

Joined: Jun 02, 2003
Posts: 1872
Hi Ramses,
A db.unlock() call from a finally{} clause sounds good to me. Notice though that the security brought by your finally clause will be higher if your method is running server-side.
I agree. Here's the link:
subject: Deadlock question
It's not a secret anymore!