priaonehaha / aforge

Automatically exported from code.google.com/p/aforge
Other
0 stars 0 forks source link

static Random doesn't work in multi threading without locking... #273

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1. use multiple threads (e.g. parallel linq) to create ActivationNetworks and 
start teaching them.
2. Eventually the static rand variable in Neuron.cs will be broken and will no 
longer generate random numbers (it will be all the same number, e.g. 0)
3. Now neural network is not usable without program restart

What version of the product are you using?
2.2.3

Please provide any additional information below.
fix by locking rand on use. lock(rand) rand.NextDouble(...)

Original issue reported on code.google.com by alexe...@gmail.com on 31 Dec 2011 at 7:08

GoogleCodeExporter commented 9 years ago

Original comment by andrew.k...@gmail.com on 31 Dec 2011 at 11:06

GoogleCodeExporter commented 9 years ago
Replaced Neuron's static random numbers generator with its thread safe version.

Committed in revision 1652. Will be released in version 2.2.4+.

P.S. That random number generator is used only when creating neural network. It 
has nothing to do with learning algorithm. 

Original comment by andrew.k...@gmail.com on 3 Jan 2012 at 11:04

GoogleCodeExporter commented 9 years ago

Original comment by andrew.k...@gmail.com on 23 Feb 2012 at 9:11