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