Created
August 11, 2014 18:21
-
-
Save kumpera/c13b5d3e5451900a94f2 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
using System.Threading; | |
using System.Threading.Tasks; | |
class MainClass { | |
public static void Main (string [] args) | |
{ | |
Test (); | |
} | |
public static void Test () | |
{ | |
const int tasksCount = 1000000; | |
var tCount = 0; | |
object o = new Object (); | |
lock (o) { | |
for (var i = 1; i < tasksCount; i++) { | |
Task.Factory.StartNew(() => { | |
lock (o) { | |
Interlocked.Increment (ref tCount); | |
}}); | |
Console.WriteLine ("{0} {1}", i, tCount); | |
} | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment