using System;
using System.Threading;
class Program {
public static void DoWork() {
Console.WriteLine("Child thread starts");
Console.WriteLine("Child thread goes to sleep");
Thread.Sleep(5000); // the thread is paused for 5000 milliseconds
Console.WriteLine("Child thread resumes and finishes");
}
public static void Main(string[] args) {
ThreadStart childJob = new ThreadStart(DoWork);
Console.WriteLine("Main thread starts");
Thread childThread = new Thread(childJob);
childThread.Start();
Console.WriteLine("Main thread waiting");
childThread.Join();
Console.WriteLine("Main thread finishes");
}
}
dXNpbmcgU3lzdGVtOwp1c2luZyBTeXN0ZW0uVGhyZWFkaW5nOwoKY2xhc3MgUHJvZ3JhbSB7CiAgcHVibGljIHN0YXRpYyB2b2lkIERvV29yaygpIHsKICAgICBDb25zb2xlLldyaXRlTGluZSgiQ2hpbGQgdGhyZWFkIHN0YXJ0cyIpOwogICAgIAogICAgIENvbnNvbGUuV3JpdGVMaW5lKCJDaGlsZCB0aHJlYWQgZ29lcyB0byBzbGVlcCIpOwogICAgIFRocmVhZC5TbGVlcCg1MDAwKTsgLy8gdGhlIHRocmVhZCBpcyBwYXVzZWQgZm9yIDUwMDAgbWlsbGlzZWNvbmRzCiAgICAgQ29uc29sZS5Xcml0ZUxpbmUoIkNoaWxkIHRocmVhZCByZXN1bWVzIGFuZCBmaW5pc2hlcyIpOwogIH0KICAKICBwdWJsaWMgc3RhdGljIHZvaWQgTWFpbihzdHJpbmdbXSBhcmdzKSB7CiAgICAgVGhyZWFkU3RhcnQgY2hpbGRKb2IgPSBuZXcgVGhyZWFkU3RhcnQoRG9Xb3JrKTsKICAgICBDb25zb2xlLldyaXRlTGluZSgiTWFpbiB0aHJlYWQgc3RhcnRzIik7CiAgICAgCiAgICAgVGhyZWFkIGNoaWxkVGhyZWFkID0gbmV3IFRocmVhZChjaGlsZEpvYik7CiAgICAgY2hpbGRUaHJlYWQuU3RhcnQoKTsKCiAgICAgQ29uc29sZS5Xcml0ZUxpbmUoIk1haW4gdGhyZWFkIHdhaXRpbmciKTsKICAgICBjaGlsZFRocmVhZC5Kb2luKCk7CiAgICAgQ29uc29sZS5Xcml0ZUxpbmUoIk1haW4gdGhyZWFkIGZpbmlzaGVzIik7CiAgfQp9