<html><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; "><div>Hi&nbsp;<span class="gmail_sendername">Gaëtan,</span></div><div>I ran an experiment calling the non-thread-safe version that is in ITK from multiple threads and had long strings of 0 when I was trying to get a uniform distribution of integers. &nbsp;96% of 1,000,000 draws were 0. &nbsp;I switched to using your version and saw a very nice looking distribution instead. &nbsp;</div><div><br></div><div>Does anyone know why the ITK version's New() operator is returning a singleton? &nbsp;Will your version, which basically eliminates the singleton and makes one of the set seed methods thread-safe be incorporated into ITK?</div><div><br></div><div>Thanks for your help,</div><div>Kris &nbsp;</div><div><br></div><blockquote type="cite"><div><div class="h5"><div class="gmail_quote">From:&nbsp;<b class="gmail_sendername">Gaëtan Lehmann</b>&nbsp;<span dir="ltr">&lt;<a href="mailto:gaetan.lehmann@jouy.inra.fr" target="_blank">gaetan.lehmann@jouy.inra.fr</a>&gt;</span><br>Date: 2011/3/11<br>Subject: Re: [Insight-users] about MersenneTwisterRandomVariateGenerator<br>To: "Suyash P. Awate" &lt;<a href="mailto:suyash@cs.utah.edu" target="_blank">suyash@cs.utah.edu</a>&gt;<br>Cc:&nbsp;<a href="mailto:insight-users@itk.org" target="_blank">insight-users@itk.org</a><br><br><br><br>Le 12 mars 11 à 03:21, Suyash P. Awate a écrit :<div><div></div><div><br><br><blockquote class="gmail_quote" style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0.8ex; border-left-width: 1px; border-left-color: rgb(204, 204, 204); border-left-style: solid; padding-left: 1ex; "><br>Hi all,<br><br>The documentation in ITK-3.2 states that the itkMersenneTwisterRandomVariateGenerator implementation isn't thread safe.<br><br>Now, if an application contains multiple threads that need to simultaneously (and throughout the program's run time) generate (independent) random-number sequences, what alternatives could be used within ITK ?<br><br>Thanks, in advance, for your suggestions,<br>Suyash<br></blockquote><br></div></div>Hi,<br><br>You can try with this modified version:<br><br>&nbsp;<a href="http://mima2.jouy.inra.fr/darcs/contrib-itk/noise/itkThreadSafeMersenneTwisterRandomVariateGenerator.cxx" target="_blank">http://mima2.jouy.inra.fr/darcs/contrib-itk/noise/itkThreadSafeMersenneTwisterRandomVariateGenerator.cxx</a><br>&nbsp;<a href="http://mima2.jouy.inra.fr/darcs/contrib-itk/noise/itkThreadSafeMersenneTwisterRandomVariateGenerator.h" target="_blank">http://mima2.jouy.inra.fr/darcs/contrib-itk/noise/itkThreadSafeMersenneTwisterRandomVariateGenerator.h</a><br><br>Regards,<br><br>Gaëtan<br><font color="#888888"><br><br>--&nbsp;<br>Gaëtan Lehmann<br>Biologie du Développement et de la Reproduction<br>INRA de Jouy-en-Josas (France)<br>tel:&nbsp;<a href="tel:%2B33%201%2034%2065%2029%2066" target="_blank"></a><a href="tel:%2B33%201%2034%2065%2029%2066" target="_blank">+33 1 34 65 29 66</a>&nbsp;&nbsp; &nbsp;fax: 01 34 65 29 09<br><a href="http://voxel.jouy.inra.fr/" target="_blank">http://voxel.jouy.inra.fr</a>&nbsp;&nbsp;<a href="http://www.itk.org/" target="_blank">http://www.itk.org</a><br><a href="http://www.mandriva.org/" target="_blank">http://www.mandriva.org</a>&nbsp;&nbsp;<a href="http://www.bepo.fr/" target="_blank">http://www.bepo.fr</a><br><br></font></div><br></div></div><span>&lt;PGP.sig&gt;</span></blockquote><div><span><br></span></div></body></html>