Lock stderr for multi-thread apps