Make variables `threadOK' and `endOfStream' volatile