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

implmenting locking methods

 
Varaku Venkata
Ranch Hand
Posts: 30
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Has anybody implemented locking and unlocking methods in the Data class ??
what are the problems if we implement in Data class ?
I have seen lot of people not implementing locking methods for local mode ? why is that so ?
Thanks
Venkat
 
Sai Prasad
Ranch Hand
Posts: 560
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
When the application operates in the local mode, there is no possiblity of having multiple threads manipulating the values in db.db. This is the reasoning behind not implementing the lock/unlock methods in Data class. There is a remote chance that this may be possible if you spawn your own thread to take care of gui actions. But I am not creating any thread in the GUI.
I am implementing the lock()/unlock() methods in the Data class because other methods in that class are already written for thread safety anyway. Also somewhere in the req document, Sun requires us to implement lock()/unlock() in the Data class. People have passed the exam by implementing lock/unlock/modify methods in a LockManager instead of Data class. It is your choice and you have to justify it.
[ May 06, 2002: Message edited by: Sai Prasad ]
 
Varaku Venkata
Ranch Hand
Posts: 30
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
thanks for the reply sai...
when you are implementing lock and unlock methods in the data class how do you control locking and unlocking not being used for local mode...
 
Sai Prasad
Ranch Hand
Posts: 560
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
In local mode only thread is going to call the lock method at any moment. So no need to control any thing.
 
Jason Boutwell
Ranch Hand
Posts: 40
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Sai wrote:
"When the application operates in the local mode, there is no possiblity of having multiple threads manipulating the values in db.db... There is a remote chance that this may be possible if you spawn your own thread to take care of gui actions."
A remote chance? Sorry, couldn't resist.
-- jason
 
Sai Prasad
Ranch Hand
Posts: 560
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Remote chance? May be not. I didn't create custom threads in GUI and may be there is a good chance for multiple threads manipulating the database. You can probably click the "Reserve" button faster than your PC?
 
John Smith
Ranch Hand
Posts: 2937
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
For the remote chance of something remote happening, I am implementing the following interface.

I am also waiting for Sun's announcement that this interface (or a corresponding tagging interface) will make it into JDK1.5.
Eugene Kononov.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic