In C language, when random values are generated, sland(time(NULL)) is often added. As far as I know, you make a random value by giving time as a seed
Generate 8 threads simultaneously in a 4-core 8-threaded environment. This thread generates randomness all at once, and the problem is that it is feared that they are repeating the same thing too much. There may be a slight difference in time between threads, but I think it may be because the seeds of time are the same as each other because they are rotated at the same time.
If anyone has thought about the precision of giving time as a seed, please give us your opinion.
c random
Seed values set by srand()
are shared by all threads.
In other words, even if srand()
is called per thread, the seed set as the last call will be used by the entire program.
When threads call time()
, the seed will eventually become the same, whether there is a time difference or not, so that each thread will not receive the same order of digits in the land()
call.
Check Linux's /dev/random or Windows' CryptGenRandom for how all threads generate random numbers regardless of seeds.
If C++ is available, you can also use random_device.
581 PHP ssh2_scp_send fails to send files as intended
613 GDB gets version error when attempting to debug with the Presense SDK (IDE)
915 When building Fast API+Uvicorn environment with PyInstaller, console=False results in an error
578 Understanding How to Configure Google API Key
574 Who developed the "avformat-59.dll" that comes with FFmpeg?
© 2024 OneMinuteCode. All rights reserved.