Changeset 7859 for trunk


Ignore:
Timestamp:
12/30/11 15:53:29 (8 years ago)
Author:
aivar
Message:

Bug with synchronization of multiple threads trying to load the native library. (Late threads would try JNA again unnecessarily.)

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/projects/curve-fitter/src/main/java/loci/curvefitter/SLIMCurveFitter.java

    r7857 r7859  
    187187 
    188188            synchronized (s_synchObject) { 
    189                 // look for library on path 
    190                 try { 
    191                     IJ.log("Using JNA"); 
    192                     s_library = (CLibrary) Native.loadLibrary("slim-curve-1.0-SNAPSHOT", CLibrary.class); 
    193                     s_libraryLoaded = true; 
    194                     s_libraryOnPath = true; 
    195                 } 
    196                 catch (UnsatisfiedLinkError e) { 
    197                     System.out.println("Library not on path " + e.getMessage()); 
    198                     IJ.log("Library not on path " + e.getMessage()); 
    199                 } 
     189 
     190                // check again to see if some other thread loaded it 
     191                if (!s_libraryLoaded) { 
     192                     
     193                    // look for library on path 
     194                    try { 
     195                        IJ.log("Using JNA"); 
     196                        s_library = (CLibrary) Native.loadLibrary("slim-curve-1.0-SNAPSHOT", CLibrary.class); 
     197                        s_libraryLoaded = true; 
     198                        s_libraryOnPath = true; 
     199                    } 
     200                    catch (UnsatisfiedLinkError e) { 
     201                        System.out.println("Library not on path " + e.getMessage()); 
     202                        IJ.log("Library not on path " + e.getMessage()); 
     203                    }  
     204                } 
     205 
    200206 
    201207                if (!s_libraryLoaded) { 
Note: See TracChangeset for help on using the changeset viewer.