Locking regex

May 16, 2010 at 12:57 PM

I want to thank you for SkyDrive as I want to incorporate it in a project. I needed the synchronizer to see how it worked, especially in a multi-threading environment. One thing that confused me was code that runs:

public static Match Match(Regex regex, string input)

Match match = null;            

lock (regex)            

{                match = regex.Match(input);          

 }            

return match;

Is this correct / needed? The regex code is thread safe.