Add lock code for thread safety regexPatternCache