creation and termination of thread