diff --git a/src/util/XMLDouble.cpp b/src/util/XMLDouble.cpp
index 5dfb94be164d082a000de9722992f4581129bbd3..98ad83184b74bab4574cc04697adad91f41870bc 100644
--- a/src/util/XMLDouble.cpp
+++ b/src/util/XMLDouble.cpp
@@ -57,8 +57,8 @@
 /*
  * $Id$
  * $Log$
- * Revision 1.13  2001/10/25 21:54:50  peiyongz
- * Apply XMLRegisterCleanup
+ * Revision 1.14  2001/10/26 16:37:46  peiyongz
+ * Add thread safe code
  *
  * Revision 1.12  2001/09/20 13:11:41  knoaman
  * Regx  + misc. fixes
@@ -133,7 +133,6 @@
 // ---------------------------------------------------------------------------
 //  class data member
 // ---------------------------------------------------------------------------
-bool XMLDouble::isInitialized = false;
 
 // ---------------------------------------------------------------------------
 //  local data member
@@ -204,6 +203,7 @@ static XMLDouble*  minNegativeValue = 0;
 static XMLDouble*  minPositiveValue = 0;
 static XMLDouble*  maxPositiveValue = 0;
 
+static XMLMutex* sDoubleMutex = 0;
 static XMLRegisterCleanup XMLDoubleCleanup;
 
 /***
@@ -314,16 +314,29 @@ void XMLDouble::init(const XMLCh* const strValue)
 //
 void XMLDouble::checkBoundary(const XMLCh* const strValue)
 {
-    if (!isInitialized)
-    {
-        isInitialized = true;  // set first to avoid recursion
-
-        maxNegativeValue = new XMLDouble(DBL_MAX_NEGATIVE);
-        minNegativeValue = new XMLDouble(DBL_MIN_NEGATIVE);
-        minPositiveValue = new XMLDouble(DBL_MIN_POSITIVE);
-        maxPositiveValue = new XMLDouble(DBL_MAX_POSITIVE);
 
-        XMLDoubleCleanup.registerCleanup(reinitXMLDouble);
+    if (!sDoubleMutex)
+    {
+        XMLMutex* tmpMutex = new XMLMutex;
+        if (XMLPlatformUtils::compareAndSwap((void**)&sDoubleMutex, tmpMutex, 0))
+        {
+            // Some other thread beat us to it, so let's clean up ours.
+            delete tmpMutex;
+        }
+        else
+        {
+            //
+            // the thread who creates the mutex succesfully, to
+            // initialize the followings
+            //
+            maxNegativeValue = new XMLDouble(DBL_MAX_NEGATIVE);
+            minNegativeValue = new XMLDouble(DBL_MIN_NEGATIVE);
+            minPositiveValue = new XMLDouble(DBL_MIN_POSITIVE);
+            maxPositiveValue = new XMLDouble(DBL_MAX_POSITIVE);
+
+            // This is the real mutex.  Register it for cleanup at Termination.
+            XMLDoubleCleanup.registerCleanup(reinitXMLDouble);
+        }
     }
 
     //
@@ -530,7 +543,8 @@ int XMLDouble::compareSpecial(const XMLDouble* const specialValue
 // -----------------------------------------------------------------------
 void XMLDouble::reinitXMLDouble() {
 
-    isInitialized = false;
+    delete sDoubleMutex;
+    sDoubleMutex = 0;
 
     delete maxNegativeValue;
     maxNegativeValue = 0;
diff --git a/src/util/XMLDouble.hpp b/src/util/XMLDouble.hpp
index d96fa73e1c005b4c4e5c49d52f0ec22b3bbcf800..afa3d2215bdd6be82d978c1955fbc9a8a5f21500 100644
--- a/src/util/XMLDouble.hpp
+++ b/src/util/XMLDouble.hpp
@@ -57,8 +57,8 @@
 /*
  * $Id$
  * $Log$
- * Revision 1.7  2001/10/25 21:54:50  peiyongz
- * Apply XMLRegisterCleanup
+ * Revision 1.8  2001/10/26 16:37:46  peiyongz
+ * Add thread safe code
  *
  * Revision 1.6  2001/09/27 14:54:20  peiyongz
  * DTV Reorganization: derived from XMLNumber
@@ -170,8 +170,6 @@ private:
     static int            compareSpecial(const XMLDouble* const specialValue
                                        , const XMLDouble* const normalValue);
 
-    static bool           isInitialized;
-
     // -----------------------------------------------------------------------
     //  Private data members
     //
diff --git a/src/util/XMLFloat.cpp b/src/util/XMLFloat.cpp
index 06f9c99e0c79fad125f7aab0c0307c14a76827c2..44c2e655eb618fb1a6e065bf3767ca8f63419903 100644
--- a/src/util/XMLFloat.cpp
+++ b/src/util/XMLFloat.cpp
@@ -57,8 +57,8 @@
 /*
  * $Id$
  * $Log$
- * Revision 1.10  2001/10/25 21:54:50  peiyongz
- * Apply XMLRegisterCleanup
+ * Revision 1.11  2001/10/26 16:37:46  peiyongz
+ * Add thread safe code
  *
  * Revision 1.9  2001/09/20 13:11:41  knoaman
  * Regx  + misc. fixes
@@ -122,11 +122,6 @@
 //
 //---------
 
-// ---------------------------------------------------------------------------
-//  class data member
-// ---------------------------------------------------------------------------
-bool XMLFloat::isInitialized = false;
-
 // ---------------------------------------------------------------------------
 //  local data member
 // ---------------------------------------------------------------------------
@@ -192,6 +187,7 @@ static XMLFloat*  minNegativeValue = 0;
 static XMLFloat*  minPositiveValue = 0;
 static XMLFloat*  maxPositiveValue = 0;
 
+static XMLMutex* sFloatMutex = 0;
 static XMLRegisterCleanup XMLFloatCleanup;
 
 /***
@@ -302,16 +298,28 @@ void XMLFloat::init(const XMLCh* const strValue)
 //
 void XMLFloat::checkBoundary(const XMLCh* const strValue)
 {
-    if (!isInitialized)
+    if (!sFloatMutex)
     {
-        isInitialized = true;  // set first to avoid recursion
-
-        maxNegativeValue = new XMLFloat(FLT_MAX_NEGATIVE);
-        minNegativeValue = new XMLFloat(FLT_MIN_NEGATIVE);
-        minPositiveValue = new XMLFloat(FLT_MIN_POSITIVE);
-        maxPositiveValue = new XMLFloat(FLT_MAX_POSITIVE);
-
-        XMLFloatCleanup.registerCleanup(reinitXMLFloat);
+        XMLMutex* tmpMutex = new XMLMutex;
+        if (XMLPlatformUtils::compareAndSwap((void**)&sFloatMutex, tmpMutex, 0))
+        {
+            // Some other thread beat us to it, so let's clean up ours.
+            delete tmpMutex;
+        }
+        else
+        {
+            //
+            // the thread who creates the mutex succesfully, to
+            // initialize the followings
+            //
+            maxNegativeValue = new XMLFloat(FLT_MAX_NEGATIVE);
+            minNegativeValue = new XMLFloat(FLT_MIN_NEGATIVE);
+            minPositiveValue = new XMLFloat(FLT_MIN_POSITIVE);
+            maxPositiveValue = new XMLFloat(FLT_MAX_POSITIVE);
+
+            // This is the real mutex.  Register it for cleanup at Termination.
+            XMLFloatCleanup.registerCleanup(reinitXMLFloat);
+        }
     }
 
     //
@@ -518,7 +526,8 @@ int XMLFloat::compareSpecial(const XMLFloat* const specialValue
 // -----------------------------------------------------------------------
 void XMLFloat::reinitXMLFloat() {
 
-    isInitialized = false;
+    delete sFloatMutex;
+    sFloatMutex = 0;
 
     delete maxNegativeValue;
     maxNegativeValue = 0;
diff --git a/src/util/XMLFloat.hpp b/src/util/XMLFloat.hpp
index 8680da115149fd0f3f789f44efe23fe933ebe95d..91dfdaa3d62e124e91db7007931114a778ddaed8 100644
--- a/src/util/XMLFloat.hpp
+++ b/src/util/XMLFloat.hpp
@@ -57,8 +57,8 @@
 /*
  * $Id$
  * $Log$
- * Revision 1.5  2001/10/25 21:54:50  peiyongz
- * Apply XMLRegisterCleanup
+ * Revision 1.6  2001/10/26 16:37:46  peiyongz
+ * Add thread safe code
  *
  * Revision 1.4  2001/09/27 14:54:20  peiyongz
  * DTV Reorganization: derived from XMLNumber
@@ -165,8 +165,6 @@ private:
     static int            compareSpecial(const XMLFloat* const specialValue
                                        , const XMLFloat* const normalValue);
 
-    static bool           isInitialized;
-
     // -----------------------------------------------------------------------
     //  Private data members
     //