public synchronized void replaceModel ( MaxentModel model ) { replacementThread = Thread . currentThread ( ) ; while ( ! replacementCanProceed ) Thread . yield ( ) ; setter . setModel ( model ) ; replacementThread = null ; }
Replace the old model with a new one forcing the replacement to wait until all threads using the old model have finished using it .