• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Major problem with record locking

 
Douglas Kent
Ranch Hand
Posts: 171
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Submitted and got feedback that my record locking was poor. Here's what I wrote, basically a two-step process that involves sleeping and polling, which I gather is the problem:
LockStruct Lstr = (LockStruct)LockArray.get(record);
synchronized (Lstr.Lock) {
while ( Lstr.Locked ) {
try {
Thread.sleep( sleepTime );
}
catch (InterruptedException ex) {}
}
Lstr.ThreadThatHasLock = Thread.currentThread();
Lstr.Locked = true;
Any suggestions?
 
Sam Wong
Ranch Hand
Posts: 133
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Off the top of my head, maybe you can try an event notification model to notify interested listeners that the record is freed. The listener may be a record locking manager that handles record locking requests. Just an idea. Hope it will spark your own ideas about this.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic