• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

My lock/unlock mechanism

 
Manish Kumar
Ranch Hand
Posts: 53
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

I have a RemoteDataFactory in which a getConnection() method has been implemented, so there is a RemoteData object for every client.
The lock and unlock methods have been implemented in Data class with the help of a LockManager. so Data object has a LockManager object.

I've used the 'current thread name' to identify the client. The lock/unlock method of RemoteData object changes the thread name to a unique name. Then it calls the lock/unlock method of the Data object.
Is there any problem with my design? Because I think this would be the only mechanism to identify the client in the Data object's lock/unlock method - without changing the signature..
I'm not locking the records in the local mode.
Please comment on my Locking mechanism.
With regards
Manish Kumar
 
Manish Kumar
Ranch Hand
Posts: 53
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Is it too complicated?
 
Max Habibi
town drunk
( and author)
Sheriff
Posts: 4118
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It seems a bit roundabout to me Manish. Have you thoght about storing the Thread Object itself, instead of it's altered name? That, coupled with a weakHashMap, could be an elegent solution.
All best,
M, author
The Sun Certified Java Developer Exam with J2SE 1.4
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic