Win a copy of AWS Security this week in the Cloud/Virtualization 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

Locking

 
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Are we allow to modify the lock(int) and the unlock(int) methods at all. For example I wanted to change lock and unlock to:
void lock(int i, Object o)
void unlock(int i, Object o)
The reason for this is that I was planning on implementing the locking mechanism as a static inner class of the Data object. I also wanted to keep track of who was locking each of the records and the Object o allows me to have each data object when calling lock or unlock use 'this' as a parameter.
Thanks for your help is advance!
 
Ranch Hand
Posts: 688
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The answer is yes, you are allow to modify anything you want, as long as you can justify the changes you made.
As far as the tracking client part, you should take a look at other posts in regard to this topic.
Personally, I don't think it's neccessary to track clients anyway.
 
Eishpal Dhillon
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yeah I was looking at a number of the other responses with regards to the locking mechanism. I think that the only way to do is to track who has which record locked. If the ArrayList, or Array or whatever you choose to implement is a static object in the Data class, such that the same locking array is accessed by each instance of the Data object. Then you have to keep track of which client has which data record locked.
But thanks for your quick response.
 
Adrian Yan
Ranch Hand
Posts: 688
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You should take a look at this post: http://www.javaranch.com/ubb/Forum25/HTML/000358.html
As a professional programmer, to me, if the requirement mentions nothing about it, I won't implement it.
That's why I'm not tracking client id at all.
 
Our first order of business must be this tiny ad:
Devious Experiments for a Truly Passive Greenhouse!
https://www.kickstarter.com/projects/paulwheaton/greenhouse-1
    Bookmark Topic Watch Topic
  • New Topic