Implemented 'template' version of spawnThreads