scripts to manage multiple threads