Implement multithreaded training and testing dataset generator.