static WeakReference < Thread > currentThreadRef ( ) { WeakReference < Thread > ref = weakThread . get ( ) ; if ( ref == null ) { ref = new WeakReference <> ( Thread . currentThread ( ) ) ; weakThread . set ( ref ) ; } return ref ; }
Returns a unique object representing the current thread . Although we use a weak - reference to the thread we could use practically anything that does not reference our class - loader .