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

The find method in the Data class

 
Ailsa Cape
Ranch Hand
Posts: 92
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi, everyone

I use the cache to store all records which are read from the database file
when the program starts, so the find method in Data class will search relative records in an ArrayList object to find which exactly match the user's criteria. I think the find method is needless to use the sychronized modifier, right?

Thanks in advance!
Regards, Ailsa Cape
 
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 Ailsa,

Well you probably don't need to synchronize the entire method, but you might still want to ensure that you are not retrieving a record from the collection at the same time that any other client is modifying the collection. So synchronization somewhere might still be in order.

Regards, Andrew
 
Ailsa Cape
Ranch Hand
Posts: 92
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi, Andrew

Thanks a million!

I think I fully understand your meaning and I must use the synchronized modifier from within the find method to prevent others modifying the collection simultaneously.

Best Regards, Ailsa Cape
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic