public static void monitor ( Object handle , ReleaseListener listener ) { if ( logger . isDebugEnabled ( ) ) { logger . debug ( "Monitoring handle [" + handle + "] with release listener [" + listener + "]" ) ; } // Make weak reference to this handle, so we can say when // handle is not used any more by polling on handleQueue. WeakReference < Object > weakRef = new WeakReference < Object > ( handle , handleQueue ) ; // Add monitored entry to internal map of all monitored entries. addEntry ( weakRef , listener ) ; }
Start to monitor given handle object for becoming weakly reachable . When the handle isn t used anymore the given listener will be called .