ostream internals are now protected by a lock, which ensures the internal state stays consistant, however, this won't prevent multiple threads to have their output ominterfering with each other, which is no different from the stl behavior. This fixes #4992