jeffheaton / encog-java-core

http://www.heatonresearch.com/encog
Other
742 stars 268 forks source link

Bug in EngineConcurrency.java #155

Closed wiemp closed 10 years ago

wiemp commented 10 years ago

Dear Jeff, I found the following issue, which seems to be a bug in EngineConcurrency.java:

In the shutdown() method, called from Encog.shutdown(), the static executor variable is set to "null". When this method is called and later during a program run, a call to setThreadCount is done (in version 3.1.0, this could be from BasicGeneticAlgorithm.java => iteration() ), the executor variable is still "null", because the initialization is never executed again and the call to executor.shutdown will fail with a null pointer exception. I therefore suggest, to add a fix to this class:

public void setThreadCount(int t) { if (this.executor != null) this.executor.shutdown(); int threads = t;

best Regards, Winfried

jeffheaton commented 10 years ago

Thank you, I added your suggested change.