init func for multithreaded programs