|
|
|
@ -132,7 +132,7 @@ class ThreadStop2 |
|
|
|
#endif |
|
|
|
#endif |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#if true |
|
|
|
#if false |
|
|
|
class SimpleBlocking |
|
|
|
class SimpleBlocking |
|
|
|
{ |
|
|
|
{ |
|
|
|
|
|
|
|
|
|
|
|
@ -168,3 +168,37 @@ class SimpleBlocking |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
#endif |
|
|
|
#endif |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#if true |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class LockingConstruct1 { |
|
|
|
|
|
|
|
private static object locker = new object(); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
static void Main() |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
long sum = 0; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Thread t1 = new Thread(delegate() |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
lock (locker) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
for (int i = 0; i <= 1000; i++) { |
|
|
|
|
|
|
|
sum += i; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Thread t2 = new Thread(delegate() |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
lock (locker) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
Console.WriteLine("Summe = " + sum); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
t1.Start(); |
|
|
|
|
|
|
|
t2.Start(); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#endif |