wood burning stoves 2.0*
The moose likes Developer Certification (SCJD/OCMJD) and the fly likes is locking required for read/find() methods? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Certification » Developer Certification (SCJD/OCMJD)
Bookmark "is locking required for read/find() methods?" Watch "is locking required for read/find() methods?" New topic
Author

is locking required for read/find() methods?

Vishwa Kumba
Ranch Hand

Joined: Aug 27, 2003
Posts: 1064
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.

thanks,
Andrew Monkhouse
author and jackaroo
Marshal Commander

Joined: Mar 28, 2003
Posts: 11404
    
  81

Hi Vishwa,

I agree with your comments. So what would you like enlightenment on?

Regards, Andrew


The Sun Certified Java Developer Exam with J2SE 5: paper version from Amazon, PDF from Apress, Online reference: Books 24x7 Personal blog
Philippe Maquet
Bartender

Joined: Jun 02, 2003
Posts: 1872
Hi Vishwa,

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.

Regards,

Phil.
Vishwa Kumba
Ranch Hand

Joined: Aug 27, 2003
Posts: 1064
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
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: is locking required for read/find() methods?
 
Similar Threads
Suggested Locking Solution
B&S Any solution if I don't want methods in the Data class to be synchronized?
Locking Mechanism
nx: All of URLy Bird 1.1.3 read/write lock(2)
URLyBird Database file