It would be better that all files are written by a sink thread that collects all produced pieces of data and then writes them down
It would be better that all files are written by a sink thread that collects all produced pieces of data and then writes them down