Win a copy of The Little Book of Impediments (e-book only) this week in the Agile and Other Processes forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Locking

 
Eishpal Dhillon
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!
 
Adrian Yan
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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic