basic function for thread creation