Re: SoftReference operation synchronization detail
- From: Thomas Hawtin <usenet@xxxxxxxxxxxxxxxxx>
- Date: Wed, 31 May 2006 19:52:14 +0100
Robert Klemme wrote:
Adding to that, here's what I'd do assuming that "cache" is an instance variable: make sure cache is always initialized with a SoftReference. If you do not have a referent initially just use new SoftReference(null). Then you can simplify your code to
[...]
The only downside of this is one additional object creation (the initial SoftReference) which usually only makes a difference if you have a lot of them.
And if you're working in the JRE, itself trying to use the technique on the thread class doesn't always work too well as the Reference static initialiser attempts to starts a new thread...
Tom Hawtin
--
Unemployed English Java programmer
http://jroller.com/page/tackline/
.
- References:
- SoftReference operation synchronization detail
- From: Stanimir Stamenkov
- Re: SoftReference operation synchronization detail
- From: Oliver Wong
- Re: SoftReference operation synchronization detail
- From: Robert Klemme
- SoftReference operation synchronization detail
- Prev by Date: Re: Is there a dedicated unicode separator character?
- Next by Date: Re: SoftReference operation synchronization detail
- Previous by thread: Re: SoftReference operation synchronization detail
- Next by thread: Re: SoftReference operation synchronization detail
- Index(es):