|
Using a Map is useful if you need to
access elements by a key, which I would guess you want, though I don't know your
requirements. However, I don't know what a TreeMap does when you try to
insert new elements when the tree is out order -- it will probably
insert into the wrong place. You probably need to store your elements in
both a List and a Map and just sort the List.
The best implementation of the sorting thread is
dependent on the performance requirements and expected usage patterns. For
example, if you can reasonably expect there there will be quiet periods, then an
interruptable, low priortity thread as you propose sounds good. However if
the system will experience continual load for extended periods the sort might
never complete. You could add a timer to force a sort after a specified
period of time, but this would force readers to block. If this is
unacceptable then you may want to go back to the idea of reinserting into a
sorted list after each access. The average performance would be
slower but the worst case would be much faster. (This is the classic
problem with using garbage collection in real-time systems.)
The trickiest part of caching in Java is dealing
with thread-safety issues with the Java Memory Model. I strongly suggest
using Doug Lea's excellent collections package to help deal with this.
See: http://gee.cs.oswego.edu/dl/classes/EDU/oswego/cs/dl/util/concurrent/intro.html
Have fun! --- 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] **************************************************************************** This e-mail, and any attachment, is intended only for the person or entity to which it is addressed and may contain confidential and/or privileged material. Any review, re-transmission, copying, dissemination or other use of this information by persons or entities other than the intended recipient is prohibited. If you received this in error, please contact the sender and delete the material from any computer. The contents of this message may contain personal views which are not the views of Discovery Communications, Inc. (DCI). **************************************************************************** |
Title: RE: [jdjlist] Re: LFUCache problem
- [jdjlist] Re: LFUCache problem Spencer W. Thomas
- [jdjlist] Re: LFUCache problem Paul Franz
- [jdjlist] Re: LFUCache problem Keats
- [jdjlist] Re: LFUCache problem Greg Nudelman
- [jdjlist] Re: LFUCache problem Keats
- [jdjlist] Re: LFUCache problem Greg Nudelman
- [jdjlist] Re: LFUCache problem Keats
- [jdjlist] Re: LFUCache problem James Stauffer
- [jdjlist] Re: LFUCache problem James Stauffer
- [jdjlist] Re: LFUCache problem James Stauffer
