• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Comment on Update()

 
Ranch Hand
Posts: 267
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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 ]
 
author and jackaroo
Posts: 12200
280
Mac IntelliJ IDE Firefox Browser Oracle C++ Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
      Number of slices to send:
      Optional 'thank-you' note:
    • 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!
    reply
      Bookmark Topic Watch Topic
    • New Topic