rand(), threads and gtkmm
- From: jody <jody xha gmail com>
- To: gtkmm-list <gtkmm-list gnome org>
- Subject: rand(), threads and gtkmm
- Date: Tue, 24 Mar 2009 15:27:24 +0100
Hi
I have an object which for its calculations creates random numbers with rand(),
and srand() is called in its constructor with a user specifiable seed.
If this object is called from another object, the sequence of random numbers
is repeated whenever the same seed is specified.
In my application this object is created in the main thread, but the
calculations
are done in a new Glib::Thread, i.e. to run the calculations i launch
a thread which
has knowledge of the object. I do this, so that i can display the
current state of
the calculations in a Gtk::Image.
In this case however, the random numbers do *not* repeat for the same
given seed.
The same behaviour takes place if the srand() is called from within the thread.
Is there something about gtkmm, threads and rand() which i am missing?
How can i get the same random numbers for the same seed in this situation?
I would prefer not to use the Glib::Rand class, because my object is
not only used
by gtkmm applications.
Thanks
Jody
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]