controlling the interruption of a thread