For the case of both Join() and lock() one thread can execute after the other.What is the main difference?
Lock is a monitor which is used to guarantee that only 1 thread can execute at a time.
lock(myobj)
{
// only 1 thread here
}
Join is used to wait for a thread to complete, before execution continues.
anotherThread.Join();
// execution here only when anotherThread is complete
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With