Using multiple threads to store data