Last post May 25, 2015 07:32 AM by gerrylowry
May 25, 2015 06:42 AM|sudip_inn|LINK
System.Threading.Thread thd1 = new System.Threading.Thread(new System.Threading.ThreadStart(DoWork));
System.Threading.Thread thd2 = new System.Threading.Thread(new System.Threading.ThreadStart(DoWork));
i just like to know why people use Thread.Join() ? Thread.Join() block next line to execute and wait for a specific thread to complete. when that specific thread is completed then next line gets executed.
just tell me the intention of Thread.Join() with right example. thanks
May 25, 2015 07:32 AM|gerrylowry|LINK
as stated in MSDN, "Blocks the calling thread until a thread terminates."
the purpose is some form of synchronization that the programmer needs to implement.
study the code here: https://msdn.microsoft.com/en-us/library/95hbf2ta(v=vs.110).aspx
pretend ThreadA processes yesterday's sales to create a report for the sales manager; ThreadB updates your sales database with yesterday's sales; you would not want ThreadA to start until ThreadB has terminated because your manager would be unhappy with
a report containing incomplete data.