aspose file tools
The moose likes Developer Certification (SCJD/OCMJD) and the fly likes Major problem with record locking Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login
JavaRanch » Java Forums » Professional Certification » Developer Certification (SCJD/OCMJD)
Reply Bookmark "Major problem with record locking" Watch "Major problem with record locking" New topic
Author

Major problem with record locking

Douglas Kent
Ranch Hand

Joined: Oct 06, 2000
Posts: 171
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

Joined: Dec 07, 2000
Posts: 133
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.
 
 
subject: Major problem with record locking
 
Threads others viewed
B&S Threads wating on a deleted Record
Passed! 149/155
Fantastic!! My RMI surprised me!!! :confused:
Deadlock during record locking
Request For Comments
developer file tools

cast iron skillet 49er

more from paul wheaton's glorious empire of web junk: cast iron skillet diatomaceous earth rocket mass heater sepp holzer raised garden beds raising chickens lawn care CFL flea control missoula heat permaculture