The Reference API in Java can leave any sane person fully confused !!!..I tried to make sense of what the different types of references are and what purpose do they solve.I am still not crystal clear about the usability of all these references, but I hope I will understand someday.
ReferentAn object that is softly, weakly, or phantomly referenced from inside a SoftReference, WeakReference, or PhantomReference object, respectively.
Soft references:
The garbage collector might or might not reclaim a softly reachable object depending on how recently the object was created or accessed, but is required to clear all soft references before throwing an OutOfMemoryError.Weakly reachable objects are finalized some time after their weak references have been cleared. The only real difference between a soft reference and a weak reference is that the garbage collector uses algorithms to decide whether or not to reclaim a softly reachable object, but always reclaims a weakly reachable object.
Phantomly reachable objects are objects that have been finalized, but not reclaimed.
The garbage collector will never clear a phantom reference. All phantom references must be explicitly cleared by the program.An excellent article explaining GC in Java is given athttp://www.artima.com/insidejvm/ed2/gc17.html
World of tricky Core Java Q and A Covering Object Oriented Analysis and Design, JVM Internals,Java Language Fundamentals,Datatypes,Keywords,Operators and Assignments,Identifies,Declarations and Modifiers, Conversion,Casting and Promotion, Flow control,Assertions, Exception Handling and Garbage Collection,Objects and Classes), Basic Packages and their classes,JDBC,JFC Swing,Java Server Pages (JSP), Servlets,EJB,JMS,JNDI etc and Open source technologies like Struts,Hibernate,Spring etc
Search This Blog
Friday, June 06, 2008
Thursday, June 05, 2008
Cool Cool The below code is in .NET C#
With JDK 1.2, Sun introducted the Java Collection Framework, a cool API for data-structures in Java. At the base of the heirarchy were collection interfaces like:
List: A collection that is ordered and whose members can be accessed by index. A list can also contain duplicates and null values.Set: A collection that is not ordered and hence there are no methods that allow to access members thru a index. Also a Set does not allow duplicates and atmost one null value.
Though I personally feel that the JDK Collection framework is quite comprehensive and should suffice most development needs, it is good to know about some other alternatives:
1) Jakarta Commons Collections - An open source initiative that contains some extra cool collections like MultiMap etc.
2) JGL (Java Generic Library) - A port of the C++ STL (Standard tag library) to the Java language. Thought I was first impressed by this package, I think this API would appleal more to those from the C++ background. Also the latest version is no longer free, I believe.
List: A collection that is ordered and whose members can be accessed by index. A list can also contain duplicates and null values.Set: A collection that is not ordered and hence there are no methods that allow to access members thru a index. Also a Set does not allow duplicates and atmost one null value.
Though I personally feel that the JDK Collection framework is quite comprehensive and should suffice most development needs, it is good to know about some other alternatives:
1) Jakarta Commons Collections - An open source initiative that contains some extra cool collections like MultiMap etc.
2) JGL (Java Generic Library) - A port of the C++ STL (Standard tag library) to the Java language. Thought I was first impressed by this package, I think this API would appleal more to those from the C++ background. Also the latest version is no longer free, I believe.
Subscribe to:
Posts (Atom)