pthread method works,pipe is used as filedescriptor that trigger select