Written detach_thread. Tests for attach_thread, resume_thread, pause_thread, detach_thread and stop_thread.