Deadlocks when writing in parallell (two processes)