Win a copy of 97 Things Every Java Programmer Should Know this week in the Java in General forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Paul Clapham
  • Jeanne Boyarsky
  • Junilu Lacar
  • Henry Wong
Sheriffs:
  • Ron McLeod
  • Devaka Cooray
  • Tim Cooke
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Frits Walraven
  • Tim Holloway
  • Carey Brown
Bartenders:
  • Piet Souris
  • salvin francis
  • fred rosenberger

Record Locking using concurrent.locks package Lock and Condition methodology

 
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi

I have come up with the following locking implementation for URLyBIRD 1.3.1.

I am using the new Lock and Condition methodology in Java concurrent.locks package. I use a map bookings to hold records that are locked.

Appreciate any opinions if this looks good or see any issues? I think it is OK but just have worries I am missing something obvious. Also was not sure whether to use sgnal or signallAll in unlockRecord method.





 
Sheriff
Posts: 11604
178
Hibernate jQuery Eclipse IDE Spring MySQL Database AngularJS Tomcat Server Chrome Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi J Flew,

First of all a remark regarding the readibility of this thread: try to limit the number of characters (e.g. 80) you put on 1 line (certainly when you use extensive comments). This will make your thread easier to read for other ranchers.

Secondly: these methods that you show, are this the implementations of Sun's interface you have to implement? Because I'm a regular visitor of this forum and I have never seen an interface where lock-method has a Data instance as a parameter. As far as I know you have 2 possible alternatives (recNo can also be a long):


And as a final remark: you can find in the ScjdFaq a link to an excellent test case to see if your solution is thread-safe. I suggest you have a look and test your solution using this test. And if you have any problems, post it here (or in that thread), because it's not our job to validate your locking mechanism. It 's something you should do on your own, because it's the most important (and hardest) part of the assignment.

Kind regards,
Roel
 
a wee bit from the empire
Devious Experiments for a Truly Passive Greenhouse!
https://www.kickstarter.com/projects/paulwheaton/greenhouse-1
    Bookmark Topic Watch Topic
  • New Topic