Attempt to lock printf to prevent output intermixing