Click here to Skip to main content
15,885,757 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: random numbers - the old bugger ... Pin
Souldrift24-Jun-09 2:29
Souldrift24-Jun-09 2:29 
AnswerRe: random numbers - the old bugger ... [modified] Pin
CPallini24-Jun-09 1:40
mveCPallini24-Jun-09 1:40 
GeneralRe: random numbers - the old bugger ... Pin
Souldrift24-Jun-09 2:29
Souldrift24-Jun-09 2:29 
QuestionRe: random numbers - the old bugger ... Pin
CPallini24-Jun-09 2:49
mveCPallini24-Jun-09 2:49 
AnswerRe: random numbers - the old bugger ... Pin
Souldrift24-Jun-09 3:06
Souldrift24-Jun-09 3:06 
AnswerRe: random numbers - the old bugger ... Pin
Stuart Dootson24-Jun-09 3:00
professionalStuart Dootson24-Jun-09 3:00 
GeneralRe: random numbers - the old bugger ... Pin
Souldrift24-Jun-09 3:12
Souldrift24-Jun-09 3:12 
GeneralRe: random numbers - the old bugger ... Pin
Stuart Dootson24-Jun-09 3:23
professionalStuart Dootson24-Jun-09 3:23 
Souldrift wrote:
Though there is only one object of the number generator and only one call of srand(). So each thread uses the same instance of the generator, which is actually what I intended because if srand()


No, no, no - each thread will have its own random number generator state - it's held inside the C run-time library (look at rand.c in the C run-time source). Even though you have one toolbox object, that's immaterial, because your object doesn't hold the random number state.

The call to srand() will only effect the thread on which the toolbox object is constructed. The other threads will get some default random number generator state initialisation.

Your best bet would be to use a different PRNG - for example, one of the implementations included in Boost[^], where (as you have full control over the PRNG including the data it uses) you could ensure that you have a single state for ALL threads. Of course, you'd then need to put a lock on the random number acquisition function (to ensure only one thread calls it at once)...

Java, Basic, who cares - it's all a bunch of tree-hugging hippy cr*p

GeneralRe: random numbers - the old bugger ... Pin
Souldrift24-Jun-09 3:29
Souldrift24-Jun-09 3:29 
QuestionNeed a help regarding crystal report Pin
tasumisra23-Jun-09 23:42
tasumisra23-Jun-09 23:42 
AnswerRe: Need a help regarding crystal report Pin
Rajesh R Subramanian24-Jun-09 1:18
professionalRajesh R Subramanian24-Jun-09 1:18 
GeneralRe: Need a help regarding crystal report Pin
tasumisra24-Jun-09 2:30
tasumisra24-Jun-09 2:30 
Questioncalling java dll from MFC Pin
sunnyram23-Jun-09 22:24
sunnyram23-Jun-09 22:24 
AnswerRe: calling java dll from MFC Pin
Stuart Dootson23-Jun-09 23:07
professionalStuart Dootson23-Jun-09 23:07 
AnswerRe: calling java dll from MFC Pin
CPallini23-Jun-09 23:11
mveCPallini23-Jun-09 23:11 
AnswerRe: calling java dll from MFC Pin
KarstenK24-Jun-09 2:37
mveKarstenK24-Jun-09 2:37 
GeneralRe: calling java dll from MFC Pin
sunnyram27-Jun-09 4:24
sunnyram27-Jun-09 4:24 
QuestionWindows update install wua api for client server Pin
ashish8patil23-Jun-09 21:57
ashish8patil23-Jun-09 21:57 
QuestionWindows message, Pin
birajendu23-Jun-09 20:52
birajendu23-Jun-09 20:52 
AnswerRe: Windows message, Pin
Stuart Dootson23-Jun-09 21:40
professionalStuart Dootson23-Jun-09 21:40 
GeneralRe: Windows message, Pin
birajendu23-Jun-09 22:21
birajendu23-Jun-09 22:21 
GeneralRe: Windows message, Pin
«_Superman_»23-Jun-09 22:23
professional«_Superman_»23-Jun-09 22:23 
GeneralRe: Windows message, Pin
birajendu23-Jun-09 22:47
birajendu23-Jun-09 22:47 
GeneralRe: Windows message, Pin
Stuart Dootson23-Jun-09 23:05
professionalStuart Dootson23-Jun-09 23:05 
GeneralRe: Windows message, Pin
Stuart Dootson23-Jun-09 23:02
professionalStuart Dootson23-Jun-09 23:02 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.