From 53e77d3628efe058639755cbc14a3bffaf47a18e Mon Sep 17 00:00:00 2001 From: Jb Evain Date: Fri, 7 Jun 2013 21:32:11 +0200 Subject: [PATCH] Prevent multiple threads to populate the keyword table --- .../System/Microsoft.CSharp/CSharpCodeGenerator.cs | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/mcs/class/System/Microsoft.CSharp/CSharpCodeGenerator.cs b/mcs/class/System/Microsoft.CSharp/CSharpCodeGenerator.cs index e5d9e5e7e66..0f8322efc76 100644 --- a/mcs/class/System/Microsoft.CSharp/CSharpCodeGenerator.cs +++ b/mcs/class/System/Microsoft.CSharp/CSharpCodeGenerator.cs @@ -1597,9 +1597,13 @@ namespace Mono.CSharp static void FillKeywordTable () { - keywordsTable = new Hashtable (); - foreach (string keyword in keywords) { - keywordsTable.Add (keyword, keyword); + lock (keywords) { + if (keywordsTable == null) { + keywordsTable = new Hashtable (); + foreach (string keyword in keywords) { + keywordsTable.Add (keyword, keyword); + } + } } } -- 2.25.1