public
Created

Patch fixing concurrency bug in fastJSON 2.0.5

  • Download Gist
JSON.patch
Diff
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23
diff --git a/fastJSON/JSON.cs b/fastJSON/JSON.cs
index d2f651e..0915fc1 100644
--- a/fastJSON/JSON.cs
+++ b/fastJSON/JSON.cs
@@ -64,7 +64,17 @@ namespace fastJSON
 
public sealed class JSON
{
- public readonly static JSON Instance = new JSON();
+ [ThreadStatic]
+ private static JSON _instance;
+
+ public static JSON Instance
+ {
+ get
+ {
+ if (_instance == null) _instance = new JSON();
+ return _instance;
+ }
+ }
 
private JSON()
{

If someone wants to use this, please also consider making JSON.Parameters a thread safe static, See my fastJSON fork on github for an example.

Please sign in to comment on this gist.

Something went wrong with that request. Please try again.