thread safe I/O