synchronized void loadLibrary0 ( String aLibraryName , Long aMajorVersion ) { if ( alreadyLoadedLibrary ( aLibraryName , aMajorVersion ) ) // our work is done. return ; List < String > libCandidates = getLibraryCandidates ( aLibraryName , aMajorVersion ) ; if ( libCandidates != null && libCandidates . size ( ) > 0 && ! loadCandidateLibrary ( aLibraryName , aMajorVersion , libCandidates ) ) { // finally, try the System.loadLibrary call try { System . loadLibrary ( aLibraryName ) ; } catch ( UnsatisfiedLinkError e ) { log . error ( "Could not load library: {}; version: {}." , aLibraryName , aMajorVersion == null ? "" : aMajorVersion ) ; throw e ; } // and if we get here it means we successfully loaded since no // exception was thrown. Add our library to the cache. setLoadedLibrary ( aLibraryName , aMajorVersion ) ; } log . trace ( "Successfully Loaded library: {}; Version: {}" , aLibraryName , aMajorVersion ) ; }
This is the method that actually loads the library . It maintains an object level lock and since this class only allows a singleton object that is a class - level lock . That means if you re loading a library on one thread other threads will block until it finishes .