public static void Vykonej() { VolatileKeyWord vkw = new VolatileKeyWord(); Thread th = new Thread(() => PomocnaMetoda(vkw)); th.Name = "sekundarni"; th.Start(); Thread.Sleep(20); vkw.ukazatel = false; Console.WriteLine("krok 2"); }
public static void PomocnaMetoda(object inst) { VolatileKeyWord vkw = (VolatileKeyWord)inst; Console.WriteLine("krok 1"); while (vkw.ukazatel) { Console.WriteLine(Thread.CurrentThread.Name); } Console.WriteLine("krok 3"); Console.ReadKey(); }