bugfixes mainly...
[mir.git] / source / mircoders / storage / DatabaseBreaking.java
index 20c8940..50af618 100755 (executable)
@@ -21,7 +21,11 @@ public class DatabaseBreaking extends Database implements StorageObject{
 
   private static DatabaseBreaking instance;
 
-  public static DatabaseBreaking 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 DatabaseBreaking getInstance() 
+    throws StorageObjectException {
     if (instance == null) {
       instance = new DatabaseBreaking();
       instance.myselfDatabase = instance;