Win a copy of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) this week in the OCAJP forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Questions! Questions! Questions!

 
Terry McKee
Ranch Hand
Posts: 175
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have read many messages that indicate that the criteriaFind method doesn't need to be synchronized. I am very confused by this because there may be concurrent usage of the criteriaFind method. Also how is everyone breaking the functionality of this method up. I am trying not to make anything complex, but I fell that the parsing of the criteria should be done in a separate class that I call ParseUtilities. Any thoughts?
 
Andras Nemeth
Ranch Hand
Posts: 80
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Terry,
The reason is that only write lock needed as it is written in the specification. It is called also dirty read.
This kind of SELECT also (may) used in SQL.
Br,
Ban
 
Terry McKee
Ranch Hand
Posts: 175
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The problem that I see is that let's say Client A and Client B both call the criteriaFind method at the same time. The method itself will have two threads running in it at the same time. Let's say that Client A is at the beginning of the method and Client B is at the end. This could cause problems. The variables that Client A and Client B are using are going to be trampled on if the method or block is synchronized.
Also, it looks like some people are loading data from the file into their program. I don't understand how that is flexible. Doesn't it make sense to keep the data where it is at? We can't guarantee that it is not a huge file.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic