using System; using System.Threading; namespace ConsoleApplication1 { class Program { static object _lock = new object(); static bool _KeepRunning = true; static bool KeepRunning { get { lock (_lock) { return _KeepRunning; } } set { lock (_lock) { _KeepRunning = value; } } } static void KillBackGroundThread() { KeepRunning = false; } static void Main(string[] args) { Thread bgThread = new Thread(new ThreadStart(MyThreadMethod)); bgThread.IsBackground = true; bgThread.Name = "Background"; bgThread.Start(); Thread.Sleep(10000); KillBackGroundThread(); } static void MyThreadMethod() { while (KeepRunning) { Console.WriteLine("Running"); Thread.Sleep(1000); } } } }