• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Questions about Lock and Unlock

 
Prakash Krishnamurthy
Ranch Hand
Posts: 154
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I had a few questions,
1) On the lock and unlock do any of you guys think it is necessary to have a read lock and a write lock separetely? If so, did you guys implement both in the lock method or did you guys have separate methods for them? The data class given to us, just has a lock and unlock method to be implemented.
2)Did you guys have a separate sub-class for the lock and unlock? I am thinking of having one. Just needed a second opinion.
3) I need to make a reference to the current thread while using the write lock and unlock methods. I am using RMI, and would like to know if should be a problem. Would RMI remember the threads associated with each client?

Regards,
Prakash
 
Juan Ec
Ranch Hand
Posts: 46
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hello Prakash. my opinions on these questions
- it's not necessary at all a read lock, and actually it is pointed in the assigment
Note that the locking required is effectively a "write" lock only.

- you can implement the lock in your Data class if you wish, but in my opinion that will not help to the clear definition of Data responsabilities. also as locking systems can be implemented in different ways, an independent class for the lock implementation will help to leave the system open for enhancements
- with rmi you can't be sure the same thread will run always on the same client, so tracking the clients with threads is not a good idea
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic