I am using locking for both update() and delete() operations, which throw SecurityException if the supplied cookie does not match.
lock() update() unlock()
Similary the delete operation.
I do not see any benefit in locking the records for read(int recNo) and find(String criteria)methods in my design, as I am using a static synchronized RAF object shared by the different instances of the Data class. I do not want any of my client threads to write to the database at the same time I am reading, but that wouldn't happen in my case as my access to the shared raf object is synchronized. Please enlighten me.
I do not want any of my client threads to write to the database at the same time I am reading
Your implementation guarantees that, OK. But be aware that - I guess as a side effect - it also guarantees that any client thread won't be able to read from the database at the same time another thread is reading.
Joined: Aug 27, 2003
Andrew: Thanks. I wanted to make sure I was walking in the right direction. I have a question on M's project.I think I'll start a different thread for it.
Phil: Yes. you are right.My use of static syncronized raf object restricts concurrent reads also.At this stage, I am not sure if I would go for read-write lock strategy, allowing concurrent reads while serializing writes, which would also require preventing read operations while a write operation is happening and vice versa. Will let you know guys, if I change my design later.At the moment, I want to get something up and running.It's been 4 months since I downloaded the assignment and haven't made much progress at all, except for... occasionally popping-in in this forum to check out how others are doing