forgot to synchronize some more DB instances
authorcvs <cvs>
Mon, 8 Apr 2002 17:50:39 +0000 (17:50 +0000)
committercvs <cvs>
Mon, 8 Apr 2002 17:50:39 +0000 (17:50 +0000)
source/mircoders/storage/DatabaseContent.java
source/mircoders/storage/DatabaseContentToMedia.java
source/mircoders/storage/DatabaseContentToTopics.java

index f4301ba..08b407e 100755 (executable)
@@ -27,7 +27,10 @@ public class DatabaseContent extends Database implements StorageObject {
 
   // Contructors / Singleton
 
-  public static DatabaseContent getInstance()
+  // 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 DatabaseContent getInstance()
     throws StorageObjectException {
 
     if (instance == null ) {
index 90854d7..5807ea5 100755 (executable)
@@ -23,7 +23,10 @@ public class DatabaseContentToMedia extends Database implements StorageObject{
 
   private static DatabaseContentToMedia instance;
 
-  public static DatabaseContentToMedia getInstance()
+  // 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 DatabaseContentToMedia getInstance()
     throws StorageObjectException {
     if (instance == null) {
       instance = new DatabaseContentToMedia();
index 8fb8a9e..dc76e9d 100755 (executable)
@@ -23,7 +23,10 @@ public class DatabaseContentToTopics extends Database implements StorageObject{
 
   private static DatabaseContentToTopics instance;
 
-  public static DatabaseContentToTopics getInstance()
+  // 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 DatabaseContentToTopics getInstance()
     throws StorageObjectException {
     if (instance == null) {
       instance = new DatabaseContentToTopics();