[ 
https://issues.apache.org/jira/browse/MATH-899?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13499680#comment-13499680
 ] 

Thomas Neidhart commented on MATH-899:
--------------------------------------

{quote}
But I have a hard time implementing a unit test that would consistently 
reproduce the error reported here: It does not necessarily happen even with a 
fairly large number of threads.
{quote}

hmm, I am not sure if this is necessary or achievable. When looking at 
comparable things (e.g. commons-collections, or openjdk), there also do not 
exist specific tests to prove that the synchronization prevents a race 
condition in not thread-safe code.

I think in this case it would be sufficient to do a proof by induction (sort 
of):

 * we know that e.g. MersenneTwister is not thread-safe
 * by providing a fully synchronized wrapper we make it thread-safe

btw. in the test you refer to MATH-900 while its actually MATH-899.
                
> A random crash of MersenneTwister random generator
> --------------------------------------------------
>
>                 Key: MATH-899
>                 URL: https://issues.apache.org/jira/browse/MATH-899
>             Project: Commons Math
>          Issue Type: Bug
>    Affects Versions: 3.0
>         Environment: Windows 7, JDK 1.7.05
>            Reporter: Alexander Nozik
>            Priority: Minor
>         Attachments: SynchronizedRandomGenerator.java, 
> SynchronizedRandomGeneratorTest.java
>
>
> There is a very small probability that MersenneTwister generator gives a 
> following error: 
> java.lang.ArrayIndexOutOfBoundsException: 624
> in MersenneTwister.java line 253
> The error is completely random and its probability is about 1e-8.
> UPD: The problem most probably arises only in multy-thread mode.

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira

Reply via email to