can write and read from pipe with threads