Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.programming.threads > #5236
| From | Bonita Montero <Bonita.Montero@gmail.com> |
|---|---|
| Newsgroups | comp.programming.threads |
| Subject | random_device-question |
| Date | 2019-10-12 09:36 +0200 |
| Organization | albasani.net |
| Message-ID | <qnrvpo$60b$1@news.albasani.net> (permalink) |
Is there any guarantee the standard makes that random_device shoudn't
start at the same internal state for all new threads, i.e. the output
of the following code is likey to be different on both lines?
#include <iostream>
#include <mutex>
#include <random>
#include <thread>
using namespace std;
int main()
{
auto thr = []()
{
static mutex mtx;
random_device rd;
mtx.lock();
cout << rd() << endl;
mtx.unlock();
};
thread t1( thr );
thread t2( thr );
t1.join();
t2.join();
}
Back to comp.programming.threads | Previous | Next — Next in thread | Find similar | Unroll thread
random_device-question Bonita Montero <Bonita.Montero@gmail.com> - 2019-10-12 09:36 +0200
Re: random_device-question Melzzzzz <Melzzzzz@zzzzz.com> - 2019-10-12 07:39 +0000
Re: random_device-question Bonita Montero <Bonita.Montero@gmail.com> - 2019-10-12 09:41 +0200
Re: random_device-question Melzzzzz <Melzzzzz@zzzzz.com> - 2019-10-12 09:10 +0000
Re: random_device-question Bonita Montero <Bonita.Montero@gmail.com> - 2019-10-12 11:30 +0200
Re: random_device-question Melzzzzz <Melzzzzz@zzzzz.com> - 2019-10-12 09:39 +0000
Re: random_device-question Bonita Montero <Bonita.Montero@gmail.com> - 2019-10-12 11:42 +0200
Re: random_device-question Bonita Montero <Bonita.Montero@gmail.com> - 2019-10-12 09:40 +0200
csiph-web