Wrap native code loading part with synchornized block

This commit is contained in:
Taro L. Saito 2011-08-01 13:57:47 +09:00
parent c4870fb505
commit 75e34c8717
3 changed files with 3 additions and 3 deletions

View File

@ -112,7 +112,7 @@ public class SnappyLoader
return isLoaded; return isLoaded;
} }
static SnappyNativeAPI load() { static synchronized SnappyNativeAPI load() {
if (isInitialized) if (isInitialized)
return api; return api;

View File

@ -31,7 +31,7 @@ public class SnappyNativeLoader
private static HashMap<String, Boolean> loadedLibFiles = new HashMap<String, Boolean>(); private static HashMap<String, Boolean> loadedLibFiles = new HashMap<String, Boolean>();
private static HashMap<String, Boolean> loadedLib = new HashMap<String, Boolean>(); private static HashMap<String, Boolean> loadedLib = new HashMap<String, Boolean>();
public static void load(String lib) { public static synchronized void load(String lib) {
if (loadedLibFiles.containsKey(lib) && loadedLibFiles.get(lib) == true) if (loadedLibFiles.containsKey(lib) && loadedLibFiles.get(lib) == true)
return; return;
@ -44,7 +44,7 @@ public class SnappyNativeLoader
} }
} }
public static void loadLibrary(String libname) { public static synchronized void loadLibrary(String libname) {
if (loadedLib.containsKey(libname) && loadedLib.get(libname) == true) if (loadedLib.containsKey(libname) && loadedLib.get(libname) == true)
return; return;