• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Comment on Update()

 
Saheed Adepoju
Ranch Hand
Posts: 267
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi all
I would like you guys to comment on my update method, I dont know whether it is thread safe and is valid for an Update(). If i do however violate any rules, please feel free to remove my post.



[Andrew: Wrapped some code so it doesnt hurt my eyes so much ]
[ February 06, 2006: Message edited by: Andrew Monkhouse ]
 
Andrew Monkhouse
author and jackaroo
Marshal Commander
Pie
Posts: 12014
220
C++ Firefox Browser IntelliJ IDE Java Mac Oracle
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Saheed,

I deleted your duplicate of this post, as it did not appear to add anything to the discussion. Please take a look at Patience is a virtue for information on why creating the second topic (which is practically the same as bumping the post) is not a good idea.

You mentioned that you are unsure whether this method is thread safe or not. Consider what would happen if two threads tried to call update at the same time (with different records):
  • Thread A might call "raf.seek(offset + ( recNo - 1...."
  • Thread B might call "raf.seek(offset + ( recNo - 1...."
  • Thread A might then start updating records
  • Which record is it going to update? What is going to stop this potential problem?

    You also mentioned that you are unsure whether this method is valid for an update(). I am unclear what you mean by that - are you asking if this method will work? If so - have you tried to update a single record using this, and did it work?

    Regards, Andrew
     
    Saheed Adepoju
    Ranch Hand
    Posts: 267
    • Mark post as helpful
    • send pies
    • Quote
    • Report post to moderator
    Good day
    Andrew, I would like to apologize for the dual post i posted. I had mistakenly hit reload of a page and i guess it reloaded my posts.
    Thanks for your insight into my question. Actually my validateRecord() is "sync"ed and i had thought it was enough to ensure that only one thread accesses the Update(). Presently i will look into your scenario and try and come up with a solution. Thanks!
     
    • Post Reply
    • Bookmark Topic Watch Topic
    • New Topic