public synchronized void addProgress ( Progress p ) { // Don't add more than once. Iterator < WeakReference < Progress >> iter = progresses . iterator ( ) ; while ( iter . hasNext ( ) ) { WeakReference < Progress > ref = iter . next ( ) ; // since we are at it anyway, remove old links. if ( ref . get ( ) == null ) { iter . remove ( ) ; } else { if ( ref . get ( ) == p ) { return ; } } } progresses . add ( new WeakReference <> ( p ) ) ; }
Add a new Progress to the tracker .