ipc and thread function