private static void addEntry ( Reference < ? > ref , ReleaseListener entry ) { synchronized ( WeakReferenceMonitor . class ) { // Add entry, the key is given reference. trackedEntries . put ( ref , entry ) ; // Start monitoring thread lazily. if ( monitoringThread == null ) { monitoringThread = new Thread ( new MonitoringProcess ( ) , WeakReferenceMonitor . class . getName ( ) ) ; monitoringThread . setDaemon ( true ) ; monitoringThread . start ( ) ; } } }
Add entry to internal map of tracked entries . Internal monitoring thread is started if not already running .