diff --git a/cs/src/Ice/ConnectionFactory.cs b/cs/src/Ice/ConnectionFactory.cs
index 564d718..d6ed702 100644
--- a/cs/src/Ice/ConnectionFactory.cs
+++ b/cs/src/Ice/ConnectionFactory.cs
@@ -136,16 +136,20 @@ namespace IceInternal
                     //
                     if(selType == Ice.EndpointSelectionType.Random)
                     {
-                        for(int j = 0; j < cons.Count - 2; ++j)
-                        {
-                            int r = rand_.Next(cons.Count - j) + j;
-                            Debug.Assert(r >= j && r < cons.Count);
-                            if(r != j)
+                        lock(rand_)
+                        {       
+                            for(int j = 0; j < cons.Count - 1; ++j)
                             {
-                                Connector tmp = cons[j];
-                                cons[j] = cons[r];
-                                cons[r] = tmp;
+                                int r = rand_.Next(cons.Count - j) + j;
+                                Debug.Assert(r >= j && r < cons.Count);
+                                if(r != j)
+                                {
+                                    Connector tmp = cons[j];
+                                    cons[j] = cons[r];
+                                    cons[r] = tmp;
+                                }
                             }
+
                         }
                     }
 
@@ -1043,15 +1047,18 @@ namespace IceInternal
                 //
                 if(_selType == Ice.EndpointSelectionType.Random)
                 {
-                    for(int j = 0; j < cons.Count - 2; ++j)
+                    lock(rand_)
                     {
-                        int r = OutgoingConnectionFactory.rand_.Next(cons.Count - j) + j;
-                        Debug.Assert(r >= j && r < cons.Count);
-                        if(r != j)
+                        for(int j = 0; j < cons.Count - 1; ++j)
                         {
-                            Connector tmp = cons[j];
-                            cons[j] = cons[r];
-                            cons[r] = tmp;
+                            int r = OutgoingConnectionFactory.rand_.Next(cons.Count - j) + j;
+                            Debug.Assert(r >= j && r < cons.Count);
+                            if(r != j)
+                            {
+                                Connector tmp = cons[j];
+                                cons[j] = cons[r];
+                                cons[r] = tmp;
+                            }
                         }
                     }
                 }
diff --git a/cs/src/Ice/Reference.cs b/cs/src/Ice/Reference.cs
index eea221f..88dae69 100644
--- a/cs/src/Ice/Reference.cs
+++ b/cs/src/Ice/Reference.cs
@@ -1377,15 +1377,18 @@ namespace IceInternal
             {
                 case Ice.EndpointSelectionType.Random:
                 {
-                    for(int i = 0; i < endpoints.Count - 2; ++i)
+                    lock(rand_)
                     {
-                        int r = rand_.Next(endpoints.Count - i) + i;
-                        Debug.Assert(r >= i && r < endpoints.Count);
-                        if(r != i)
+                        for(int i = 0; i < endpoints.Count - 1; ++i)
                         {
-                            object tmp = endpoints[i];
-                            endpoints[i] = endpoints[r];
-                            endpoints[r] = tmp;
+                            int r = rand_.Next(endpoints.Count - i) + i;
+                            Debug.Assert(r >= i && r < endpoints.Count);
+                            if(r != i)
+                            {
+                                object tmp = endpoints[i];
+                                endpoints[i] = endpoints[r];
+                                endpoints[r] = tmp;
+                            }
                         }
                     }
                     break;
