add stderr lock for multiple threads/processes