Thank you for your attempt to help me, toutarrive, but this does not work. The point is that, in the case there is no input data available on stdin, the thread keeps waiting for this input data (which may never appear).
Therefore, if there will be no input data, this test "while (!isThreadstopped) of yours is done only once. I nevertheless tried this loop, but, as I expected, it did not help.