This week's book giveaway is in the Clojure forum.
We're giving away four copies of Clojure in Action and have Amit Rathore and Francis Avila on-line!
See this thread for details.
Win a copy of Clojure in Action this week in the Clojure forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

is locking required for read/find() methods?

 
Vishwa Kumba
Ranch Hand
Posts: 1066
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Pie
Posts: 11833
181
C++ Firefox Browser IntelliJ IDE Java Mac Oracle
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Vishwa,

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

Regards, Andrew
 
Philippe Maquet
Bartender
Posts: 1872
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 1066
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic