Re: SoftReference operation synchronization detail
- From: stamenkov@xxxxxxxxx
- Date: 31 May 2006 10:51:12 -0700
/Oliver Wong/:
Note that the reference called "cache" won't
magically turn into null behind your back. It's only the referent within the
SoftReference which may become null (which is why get() sometimes returns
null). So depending on the design of the rest of your code, the check for
cache != null might be unnescessary.
I haven't used the Reference classes up to now and seems I haven't
quite understood the description
<http://java.sun.com/j2se/1.4.2/docs/api/java/lang/ref/SoftReference.html>:
Suppose that the garbage collector determines at a certain point in
time that an object is softly reachable. At that time it may choose
to clear atomically all soft references to that object...
The "choose to clear all soft references" part now I understand as
clear the references to the objects those Reference objects hold,
right?
But my main concern was because of some test of mine (not clear enough
thought) while playing with those Reference classes - I've got 'null'
values for the Reference variables themselves, after I have initialized
them. And reading further into the description:
... At the same time or at some later time it will enqueue those
newly-cleared soft references...
I don't understand how are the references processed from those queues,
given the they have already been cleared, but I've speculated that
process might have cleared my Reference variables, somehow. It is quite
possible I haven't overseen something, too.
That sounds most logical, but again: a Reference variable is never
cleared automatically?
--
Stanimir
.
- Follow-Ups:
- Re: SoftReference operation synchronization detail
- From: Thomas Hawtin
- Re: SoftReference operation synchronization detail
- From: Oliver Wong
- Re: SoftReference operation synchronization detail
- References:
- SoftReference operation synchronization detail
- From: Stanimir Stamenkov
- Re: SoftReference operation synchronization detail
- From: Oliver Wong
- SoftReference operation synchronization detail
- Prev by Date: Re: create jar file with external jar library
- 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):
Relevant Pages
|
|