File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Developer Certification (SCJD/OCMJD) and the fly likes Final question : A deep thought on the criteriaFind Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login
JavaRanch » Java Forums » Professional Certification » Developer Certification (SCJD/OCMJD)
Reply Bookmark "Final question : A deep thought on the criteriaFind" Watch "Final question : A deep thought on the criteriaFind" New topic
Author

Final question : A deep thought on the criteriaFind

Karl Fu
Ranch Hand

Joined: Mar 26, 2001
Posts: 41
This is the my final question to this assignment !
I presume most of us will have a vector or other collection stuff to hold successful matches, which very likely to be initialized within the criteriaFind method.
say there are 2 user connecting to the database, both user call the criteriaFind method at the same time. When A pass in a string and he find some successful match, after he added a few successful match, his thread stops.
Client B kicks in with a different search string, initialized a new Vector....did his search....and add some record to the vector, right before he returns the matched record, he thread stops and client A continue with what he left off.
The vector initialized by B should have covered up and erased what client A had already put in the vector previously(before his thread stops), this should have lead to some display inconsistency..
However, with quite alot of testing so far..I have never come across any inconsistency with my criteriaFind method. Does it suggest that variables initialized within the method will not be affected by other threads accessing the same method ? Or is it because of other reasons ?
Any comment is appreciate !
Karl
Narayan Veeramani
Greenhorn

Joined: Jun 06, 2001
Posts: 25
I presume that you have the vector locally declared within
the method (not a member variable of the class). In this
case, there won't be any problem with multiple threads
accessing the criteriaFind method.
But still I am declaring this method as synchronized because
the method uses the file pointer to iterate through the database file. So if multiple threads are concurrently allowed to execute this method, the file pointer (of the member variable RandomAccessFile) may get messed up.
 
 
subject: Final question : A deep thought on the criteriaFind
 
Threads others viewed
Synchronization of public methods in DVDDatabase
search algorithm: clarity and efficiency
Locking confusion -- help
FBNS: Inherit from Data class and How to operate db.db
criteriaFind
WebSphere development made easy
without the weight of IBM tools
http://www.myeclipseide.com

cast iron skillet 49er

more from paul wheaton's glorious empire of web junk: cast iron skillet diatomaceous earth rocket mass heater sepp holzer raised garden beds raising chickens lawn care CFL flea control missoula heat permaculture