• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Bear Bibeault
  • Ron McLeod
  • Jeanne Boyarsky
  • Paul Clapham
Sheriffs:
  • Tim Cooke
  • Liutauras Vilda
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • fred rosenberger
  • salvin francis
Bartenders:
  • Piet Souris
  • Frits Walraven
  • Carey Brown

Lock Unlock record some confusion.

 
Ranch Hand
Posts: 70
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I yet not functionally started assignment, but doing groundwork, writing small small patch of code with db.db.
I confused with implementing with Lock & Unlock methods since they ought to be called from client.
In order to track the client while executing Locking / Unlocking mechanism over Database record, Client Id has to be passed. By which way we can pass client id to the server, So we can ensure this client acquired the lock on the record.
Since we have lock / Unlock / Modify are separate methods how come we can ensure thread safeness by Synchronized(DataInfo_obj).
I can find the way out.
 
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
You can find which client wants to lock the record by calling this.
Thread caller = Thread.currentThread();
then find out if the caller is same as owner then you need not wait to lock again, if not wait for the record to be unlocked.
Thanks.
 
ranger
Posts: 17346
11
Mac IntelliJ IDE Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You can use getCurrentThread() if you are using Object Serialization, if you chose RMI you need to read most of the other Lock, Unlock posts on this newsgroup. The answer is out there.
We are not alone
Mark
 
author
Posts: 3252
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Originally posted by Mark Spritzler:
You can use getCurrentThread() if you are using Object Serialization

But can you? Do you have a rock-solid guarantee that no two Threads are identical in different JVMs?
- Peter

 
Mark Spritzler
ranger
Posts: 17346
11
Mac IntelliJ IDE Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Don't know. I think that all comes down to how JVM creates thread identifiers. Or would the chance of them being the same 1 in infinity? I wonder if they are created using a random generator based on the time in milliseconds?
Anyway I am using RMI, so I didn't have to come across that issue. Maybe I could use that as a consideration on my essay exam on why I chose RMI.
Just a thought, I don't know .
Mark
[This message has been edited by Mark Spritzler (edited October 19, 2001).]
 
Don't get me started about those stupid light bulbs.
    Bookmark Topic Watch Topic
  • New Topic