Made thread safe for experiment.

Not sure why the file reading needs to be locked
in the learning method. Different threads should be able
to get file handles on a single file, especially if only
for reading (as the training file is read). This ran
formerly on Windows, not sure what's different on OS X.
Perhaps it's something else, I haven't been able to pinpoint
the exact cause of the threading exception.

Regarding debugging to get an exact answer, pdb crashes with
the application and gdb gives info too far removed from the
actual code. It is working now, albeit lacking efficiency.