Click or drag to resize
Accord.NET (logo)

ThreadSafeRandom Class

Note: This API is now obsolete.

Thread safe version of the Random class.
Inheritance Hierarchy
SystemObject
  SystemRandom
    AccordThreadSafeRandom

Namespace:  Accord
Assembly:  Accord (in Accord.dll) Version: 3.8.0
Syntax
[ObsoleteAttribute("Prefer the use of ThreadLocal over shared Random objects.")]
public sealed class ThreadSafeRandom : Random
Request Example View Source

The ThreadSafeRandom type exposes the following members.

Constructors
  NameDescription
Public methodThreadSafeRandom
Initializes a new instance of the ThreadSafeRandom class.
Public methodThreadSafeRandom(Int32)
Initializes a new instance of the ThreadSafeRandom class.
Top
Methods
  NameDescription
Public methodEquals
Determines whether the specified object is equal to the current object.
(Inherited from Object.)
Public methodGetHashCode
Serves as the default hash function.
(Inherited from Object.)
Public methodGetType
Gets the Type of the current instance.
(Inherited from Object.)
Public methodNext
Returns a nonnegative random number.
(Overrides RandomNext.)
Public methodNext(Int32)
Returns a nonnegative random number less than the specified maximum.
(Overrides RandomNext(Int32).)
Public methodNext(Int32, Int32)
Returns a random number within a specified range.
(Overrides RandomNext(Int32, Int32).)
Public methodNextBytes
Fills the elements of a specified array of bytes with random numbers.
(Overrides RandomNextBytes(Byte).)
Public methodNextDouble
Returns a random number between 0.0 and 1.0.
(Overrides RandomNextDouble.)
Public methodToString
Returns a string that represents the current object.
(Inherited from Object.)
Top
Extension Methods
  NameDescription
Public Extension MethodHasMethod
Checks whether an object implements a method with the given name.
(Defined by ExtensionMethods.)
Public Extension MethodIsEqual
Compares two objects for equality, performing an elementwise comparison if the elements are vectors or matrices.
(Defined by Matrix.)
Public Extension MethodTo(Type)Overloaded.
Converts an object into another type, irrespective of whether the conversion can be done at compile time or not. This can be used to convert generic types to numeric types during runtime.
(Defined by ExtensionMethods.)
Public Extension MethodToTOverloaded.
Converts an object into another type, irrespective of whether the conversion can be done at compile time or not. This can be used to convert generic types to numeric types during runtime.
(Defined by ExtensionMethods.)
Top
Remarks

The class inherits the Random and overrides its random numbers generation methods providing thread safety by guarding call to the base class with a lock. See documentation to Random for additional information about the base class.

See Also