Win a copy of The Little Book of Impediments (e-book only) this week in the Agile and Other Processes forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Which methods of DB interface did you make thread-safe?

 
Roman Yankin
Ranch Hand
Posts: 47
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
My implementation was almost absolutely strait-forward. I have synchronized everything except DB#find() method. My argument was that it is ok to show a bit obsolete search-results, but its much worse to lock everything while search operation is running as it might take a significant amount of time

What was your decision?
 
Jeffry Kristianto Yanuar
Ranch Hand
Posts: 759
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I lock all the access to the database. In my find() method, I use shared RandomAccessFile object to find the result as well as all the other methods.

hope that helps.

Jeffry Kristianto Yanuar
Java Instructor
SCJP 5.0
SCJA
SCJD (Working on UrlyBird 1.3.2) --> preparing to upload
 
Jevgeni Zhukov
Greenhorn
Posts: 18
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The only method I entirely synchronized was deleteRecord(). In find() method I only synchronized getting of database length. In other methods: read(), update(), create(), I only synchronized a block of code responsible for checking and reading/writing record.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic