[C#] SemaphoreSlim based solution
csharp\nusing System.Threading;\n\npublic class ZeroEvenOdd\n{\n    private int n;\n    \n    private SemaphoreSlim zeroLock = new SemaphoreSlim(1, 1);\n    pri
```csharp\nusing System.Threading;\n\npublic class ZeroEvenOdd\n{\n    private int n;\n    \n    private SemaphoreSlim zeroLock = new SemaphoreSlim(1, 1);\n    private SemaphoreSlim evenLock = new SemaphoreSlim(0, 1);\n    private SemaphoreSlim oddLock = new SemaphoreSlim(0, 1);\n    \n    public ZeroEvenOdd(int n)\n    {\n        this.n = n;\n    }\n\n    public void Zero(Action<int> printNumber)\n    {\n        for (var i = 1; i <= n; i++)\n        {\n            zeroLock.Wait();\n            printNumber(0);\n            \n            if (i % 2 == 0)\n            {\n                evenLock.Release();\n            }\n            else\n            {\n                oddLock.Release();\n            }\n        }\n    }\n\n    public void Even(Action<int> printNumber)\n    {\n        for (var i = 2; i <= n; i += 2)\n        {\n            evenLock.Wait();\n            printNumber(i);\n            zeroLock.Release();\n        }\n    }\n\n    public void Odd(Action<int> printNumber)\n    {\n        for (var i = 1; i <= n; i += 2)\n        {\n            oddLock.Wait();\n            printNumber(i);\n            zeroLock.Release();\n        }\n    }\n}\n```
['C#']