Use a fifo pipe to handle the synchronisation between the different threads rather than relying on delays
Issue #3373.