• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

How many lock can a thread have?.

 
Muthaiah Ramanathan
Ranch Hand
Posts: 102
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Guys,

I am trying to find out if restricting the number of locks a thread can hold, is advised or not?

For eg assume the following situation:
thread 1 has a lock for record 15.
thread 2 has a lock for record 16.
thread 1 tries to acquire the lock for record 16.
thread 2 tries to acquire the lock for record 15.

A deadlock will happen here. If we restrict the number of locks a thread can hold at a time, this situation can be solved.

I'm thinking about this, but don't know if this is recommended or not?

If yes, can I use 'Thread.currentThread().getName()' store in a hashtable (along with the cookie)?

(Pls note that in my design, the LockManager is not aware of the CLIENT who requests for a lock)

Your suggestions will be much appreciated.

Regards,

Muthaiah.
 
Oricio Ocle
Ranch Hand
Posts: 284
Debian Firefox Browser Netbeans IDE
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello again Muthaiah.
This is a good question.
Take a look to this thread
Regards, Ori
 
Muthaiah Ramanathan
Ranch Hand
Posts: 102
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Oricio,

Thanks. I will stay from those thoughts then.

Regards,

Muthaiah.
 
Muthaiah Ramanathan
Ranch Hand
Posts: 102
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Also I learned from the earlier posts that the RMI ENGINE makes no guarantee that it will make a new thread for each client. So to use 'Thread.currentThread().getName()' for identifying which thread locked the record would be un-trusted.

Regards,

Muthaiah
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic