using foreground thread for timeout loop