Merge pull request #76 from lukeabsent/AMQNET-722

AMQNET 722 little addition 
diff --git a/docs/configuration.md b/docs/configuration.md
index 2c81986..c414126 100644
--- a/docs/configuration.md
+++ b/docs/configuration.md
@@ -71,5 +71,6 @@
 - **failover.maxReconnectDelay** The maximum time that the client will wait before attempting a reconnect. This value is only used when the backoff feature is enabled to ensure that the delay doesn't not grow too large. Defaults to 30 seconds as the max time between connect attempts.
 - **failover.useReconnectBackOff** Controls whether the time between reconnection attempts should grow based on a configured multiplier. This option defaults to true.
 - **failover.reconnectBackOffMultiplier** The multiplier used to grow the reconnection delay value, defaults to 2.0d.
+- **failover.reconnectDelayRandomFactor** Reconnect backoff random factor. 0 means no randomisation. 0.5 would mean backoff time could be (pseudo)randomly between 0.5 and 1.5 of normal reconnect backoff time. 1 would mean backoff time could be between 0 and 2x normal reconnect backoff. 2 would mean backoff time between 0 and 3x normal backoff, and so on. Default value is 0. 
 - **failover.maxReconnectAttempts** The number of reconnection attempts allowed before reporting the connection as failed to the client. The default is no limit or (-1).
 - **failover.startupMaxReconnectAttempts** For a client that has never connected to a remote peer before this option control how many attempts are made to connect before reporting the connection as failed. The default is to use the value of maxReconnectAttempts.
\ No newline at end of file
diff --git a/src/NMS.AMQP/Provider/Failover/FailoverProvider.cs b/src/NMS.AMQP/Provider/Failover/FailoverProvider.cs
index 25f6529..faebe3e 100644
--- a/src/NMS.AMQP/Provider/Failover/FailoverProvider.cs
+++ b/src/NMS.AMQP/Provider/Failover/FailoverProvider.cs
@@ -674,12 +674,19 @@
                     }
                 }
 
-                long randomFactor = (long) ((1 - 2 * random.NextDouble()) *
-                                            failoverProvider.ReconnectDelayRandomFactor * nextReconnectDelay);
+                long randomFactor = (long)((1 - 2 * GetRandomDouble()) * failoverProvider.ReconnectDelayRandomFactor * nextReconnectDelay);
 
-                return Math.Min(failoverProvider.MaxReconnectDelay, nextReconnectDelay + randomFactor);
+                return Math.Max(0, Math.Min(failoverProvider.MaxReconnectDelay, nextReconnectDelay + randomFactor));
             }
 
+            private double GetRandomDouble()
+            {
+                lock (random) // Random is not thread safe
+                {
+                    return random.NextDouble();
+                }
+            }
+            
             public long RecordNextAttempt()
             {
                 return ++reconnectAttempts;