Review: Factor out the memory allocation from thread function to preparation function..