Thread synchronisation for io operations