Like This Site? 
 
RSS Feed Follow Us 

on Twitter! Be Our Fan!

A Tutorial On Weak References

Share this post!
 Vote this!

Strong references
First I need to start with a refresher on strong references. A strong reference is an ordinary Java reference, the kind you use every day. For example, the code:

StringBuffer buffer = new StringBuffer();

creates a new StringBuffer() and stores a strong reference to it in the variable buffer. Yes, yes, this is kiddie stuff, but bear with me. The important part about strong references — the part that makes them “strong” — is how they interact with the garbage collector. Specifically, if an object is reachable via a chain of strong references (strongly reachable), it is not eligible for garbage collection. As you don’t want the garbage collector destroying objects you’re working on, this is normally exactly what you want.

More... 

0 comments:

Post a Comment