Return-Path: X-Original-To: apmail-commons-issues-archive@minotaur.apache.org Delivered-To: apmail-commons-issues-archive@minotaur.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 6B989D7E4 for ; Sat, 17 Nov 2012 00:47:13 +0000 (UTC) Received: (qmail 53209 invoked by uid 500); 17 Nov 2012 00:47:13 -0000 Delivered-To: apmail-commons-issues-archive@commons.apache.org Received: (qmail 53120 invoked by uid 500); 17 Nov 2012 00:47:13 -0000 Mailing-List: contact issues-help@commons.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: issues@commons.apache.org Delivered-To: mailing list issues@commons.apache.org Received: (qmail 52900 invoked by uid 99); 17 Nov 2012 00:47:12 -0000 Received: from arcas.apache.org (HELO arcas.apache.org) (140.211.11.28) by apache.org (qpsmtpd/0.29) with ESMTP; Sat, 17 Nov 2012 00:47:12 +0000 Date: Sat, 17 Nov 2012 00:47:12 +0000 (UTC) From: "Gilles (JIRA)" To: issues@commons.apache.org Message-ID: <533930159.126549.1353113232942.JavaMail.jiratomcat@arcas> In-Reply-To: <416341349.122957.1353053412346.JavaMail.jiratomcat@arcas> Subject: [jira] [Commented] (MATH-899) A random crash of MersenneTwister random generator MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-JIRA-FingerPrint: 30527f35849b9dde25b450d4833f0394 [ https://issues.apache.org/jira/browse/MATH-899?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13499284#comment-13499284 ] Gilles commented on MATH-899: ----------------------------- Actually, it was Thomas's suggestion that we could provide an implementation of "RandomGenerator" that, IIUC, would wrap another instance and override all the methods with the "synchronized" keyword. {code} /** * Any "RandomGenerator" can be thread-safe if it is used through * an instance of this class. */ public class SynchronizedRandomGenerator { private final RandomGenerator wrapped; /** * @param rng Generator whose methods will be called through * their corresponding overridden synchronized version. * To ensure thread-safety, the wrapped generator must * not be used directly. */ public SynchronizedRandomGenerator(RandomGenerator rng) { wrapped = rng; } public synchronized void setSeed(int seed) { wrapped.setSeed(seed); } // [Similarly for all methods.] } {code} Any caveat with that solution? > 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 > > 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