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

[NX: URLyBird] thread safe Data objects?

 
Chris Hegarty
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have an implementation of the Data class ( used to access the database file) that is not thread-safe. I have one Data object to each client connection and synchronize write/delete/update through a locking mechanism using static member objects. This implementation will maintain database integraty when each client serializes it's calls to the Data object.
The data class can easily be converted to be thread-safe by simply adding 'synchronize' to each of the member function declarations. This should not effect the performance of the data access too much ( there will not be any contention on the object).
My question is; is it better to have the Data class thread-safe or not? It is not part of my specific project requirements, but maybe for future client development?
 
Bharat Ruparel
Ranch Hand
Posts: 493
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello Chris,
I also have URLy Bird assignment and I have done the thread management with Andrew and Max's help in the following thread (post) really. I suggest you go through it thoroughly. There are a number of other threads out there as well on this topic. They pretty much walked me through the development of what I think is a rather neat solution. Enjoy!
Topic: NX: About data consistent
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic