Forums Register Login

Reading a locked record.

+Pie Number of slices to send: Send
Hi there...

I am currently working on UrlyBird 1.2.3. And have a question that may also apply to other asignments.

Will it be correct to wait for a locked record to become unlocked before i read from it?

My interface specifies this on reads:



+Pie Number of slices to send: Send
Hi Kasper,

Welcome to the JavaRanch!

I guess that will have an enormous performance decrease. When reading records I didn't care about a record being locked or not. Every valid (= not deleted) record is read immediately, without waiting until it is unlocked.

Kind regards,
Roel
+Pie Number of slices to send: Send
I had ReadWriteLock on my data access layer, which would control RandomAccessFile, but that had nothing to do with locks of Data class.
+Pie Number of slices to send: Send
I chose a solution where i read locked records, but have synchronized access to my data. In this way data can be dirty in the application, but it will never be dirty upon read.

I also have made a record comparator, so i can compare the data shown, after a search with data in the "database", this way i can check if data has been changed.

So when you are going to make a booking of a room, you lock the record, compare and update your data, and the user will be presented with a choice to continue booking if data has been changed from the search to the booking.
Beauty is in the eye of the tiny ad.
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com


reply
reply
This thread has been viewed 806 times.
Similar Threads
delete in B&S
NX: Bodgitt and Scarper and design/synchronization questions
No definition of what is a DuplicateKeyException
Is my locking mechanism going to work?
URLyBird 1.2.1 - read for update
More...

All times above are in ranch (not your local) time.
The current ranch time is
Mar 28, 2024 13:11:22.