RE: [jdjlist] Re: LFUCache problemIf you synchronize *ALL* access methods you shouldn't have any thread-safety issues. Of course this comes at a cost in performance. Since caching is generally done for performance reasons, folks generally want to reduce the impact of locking and lock contention. Unfortunately, the limitations of the Java Memory Model (JMM) make it tricky to do this properly. AFAIK, Doug Lea was the first person to produce code that allows unblocked reads to a collection that has been shown to be safe in any conformant JVM. I understand his approach is slated for inclusion in the next release of Java.
I learned most of this stuff from my colleague Brian Goetz. You can read his article on the subject: http://www-106.ibm.com/developerworks/java/library/j-jtp07233.html. Testing is definitely a challenge for this type of application. You need to have agents running on multiple boxes to do a decent test. Even after thorough testing you may still miss errors that are JVM specific unless you are fully compliant with the JLS. I don't have a lot of experience with testing tools, but a good place to start may be Apache JMeter: http://jakarta.apache.org/jmeter/index.html Keats ----- Original Message ----- From: Greg Nudelman To: jdjlist Sent: Friday, November 14, 2003 2:51 PM Subject: [jdjlist] Re: LFUCache problem Dear Keats, Thank you so much for the input. I thought about this problem for a few days more and I figured out that I can get everything done with a single data-structure, a Hashtable with a real-time selection algorithm. I'm writing the code now and will test the performance, and try to post a link here as soon as it is done (it's labor of love, as you can tell, so it may take a while :-) One question though: > The trickiest part of caching in Java is dealing with thread-safety issues with the Java Memory Model. If I have a real-time synchronized public access methods and nothing running as a background thread, do I need to worry about any kind of locking issues for my cache, or should Java mostly take care of it? I'm going to have a hell of a time testing this with multiple threads... does anyone have a simple, good thread testing class I can use that I can test cache concurrency on? Look for my code coming soon, I hope some else can use it also. Thank you again everyone for the input. I really appreciate being a part of a knowledgeable support group like this, it makes the projects a lot more fun! Happy Friday and a Good Weekend to all, Greg --- You are currently subscribed to jdjlist as: [EMAIL PROTECTED] To unsubscribe send a blank email to [EMAIL PROTECTED] http://www.sys-con.com/fusetalk To unsubscribe from all mailing lists, click: http://sys-con.com/[EMAIL PROTECTED]
