Exemplo n.º 1
0
 // Начать выполнение нового потока.
 void Run()
 {
     Console.WriteLine(Thrd.Name + " начат.");
     answer = sa.SumIt(a);
     Console.WriteLine("Сумма для потока " + Thrd.Name + " равна " + answer);
     Console.WriteLine(Thrd.Name + " завершен.");
 }
Exemplo n.º 2
0
 // Begin execution of new thread.
 void Run()
 {
     Console.WriteLine(Thrd.Name + " starting.");
     answer = sa.SumIt(a);
     Console.WriteLine("Sum for " + Thrd.Name + " is " + answer);
     Console.WriteLine(Thrd.Name + " terminating.");
 }
Exemplo n.º 3
0
    // Begin execution of new thread.
    void Run()
    {
        Console.WriteLine(Thrd.Name + " starting.");

        // Lock calls to SumIt().
        lock (sa) answer = sa.SumIt(a);
        Console.WriteLine("Sum for " + Thrd.Name + " is " + answer);
        Console.WriteLine(Thrd.Name + " terminating.");
    }
 void Run()
 {
     Console.WriteLine("Thread \"" + this.Thread.Name + "\" start running");
     lock (sa) this.answer = sa.SumIt(this.a);
     Console.WriteLine(
         "Sum for \"" + this.Thread.Name
         + "\" equal " + this.answer
         );
     Console.WriteLine("Thread \"" + this.Thread.Name + "\" end  running");
 }