bugfixes mainly...
[mir.git] / source / mircoders / storage / DatabaseMedia.java
index de0e294..fa09f08 100755 (executable)
@@ -22,7 +22,11 @@ public class DatabaseMedia extends Database implements StorageObject{
   private static DatabaseMedia instance;
   private static EntityRelation         relationMediaType;
 
-  public static DatabaseMedia getInstance() throws StorageObjectException {
+  // the following *has* to be sychronized cause this static method
+  // could get preemted and we could end up with 2 instances of DatabaseFoo..
+  // see the "Singletons with needles and thread" article at JavaWorld -mh
+  public synchronized static DatabaseMedia getInstance() 
+    throws StorageObjectException {
     if (instance == null) {
       instance = new DatabaseMedia();
       instance.myselfDatabase = instance;