Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

setSeed() should throw an exception #9

Open
cowwoc opened this issue Apr 30, 2013 · 2 comments
Open

setSeed() should throw an exception #9

cowwoc opened this issue Apr 30, 2013 · 2 comments

Comments

@cowwoc
Copy link

cowwoc commented Apr 30, 2013

Following up on your post at http://blog.uncommons.org/2012/11/22/uncommons-maths-1-2-3/ you can solve the problem by doing the following:

  1. Add field private AtomicBoolean inConstructor = true.
  2. When setSeed() is invoked, it only throws an exception if inConstructor is false.
  3. At the end of the subclass constructor, set inConstructor to false.

Problem solved :)

@dwdyer
Copy link
Owner

dwdyer commented May 1, 2013

Yes, that looks like a workable solution. Thanks.

@cowwoc
Copy link
Author

cowwoc commented May 1, 2013

You're welcome. Slight correction on the field definition, it should be:

private final AtomicBoolean inConstructor = new AtomicBoolean(true)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants