Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8138831
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T11:37:42+00:00 2026-06-06T11:37:42+00:00

Almost every pseudorandom generator in C/C++ (Mersenne, …) uses some kind of internal state,

  • 0

Almost every pseudorandom generator in C/C++ (Mersenne, …) uses some kind of internal state, usually a short vector of bytes. My question is, when such a random generator is used and shared in a multithreaded environment is it “much” better to have it thread-safe or letting “race conditions” to occur can only increases randomness?

I know this question is extremely hard to answer rigorously but will appreciate any opinions.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-06T11:37:44+00:00Added an answer on June 6, 2026 at 11:37 am

    Concurrent write

    It highly depends on the kind of internal state. If every possible bit pattern is a valid representation of internal state, and will therefore occur at some point of the random number sequence, then having write races should be no problem. But many random number generators, including the Mersenne you quoted, have a period which is not a power of 256, therefore have some state patterns which are never reached in single-threaded operation and might cause problems in multi-threaded operation.

    Concurrent read

    But there is an even better reason to make the rng thread-safe: otherwise two processes might read the same state before either one can update it. This can lead to two processes sharing exactly the same random number, which can lead to all kinds of bizarre problems, depending on your application. You can make it thread-sdafe either using mutexes or thread-local state.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Almost every ios app now has something like Feed option. Programming that usually includes
Just for kind of fun I'm developing almost every algorithm (if possible) shown in
well for some strange reason IE gives me and InvalidAuthenticityToken error almost every time
Almost every project that I work will have some sort of tab delimited file
Almost every developer that uses a Mac practically worships TextMate. Why? What extraordinary features
The TreeView uses in its underlying implementation the TreeNodeCollection. The TreeNodeCollection in almost every
I have always wondered that since Qt uses almost every C++ feature in the
I have a PHP page with multiple mysql_query instances. Almost every one uses a
Almost every programmer did it once in his life: setting some flag if a
Almost every other program or function designed to copy one object into another uses

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.