Lakshmi
Lakshmi

Reputation: 179

What is the difference between C# Thread.Sleep() and threadreference.Join()?

What is the difference between C# Thread.Sleep() and threadreference.Join()?

Upvotes: 3

Views: 3012

Answers (2)

JaredPar
JaredPar

Reputation: 755209

Sleep is a method which suspends a thread for a period of time. It acts on a single thread.

Join is a method which suspends a thread until another thread has finished. It can be configured to sleep infinitely until that thread completes or for a finite period of time or until the other thread completes. This is a method for synchronization between multiple threads.

Upvotes: 11

Erik Kerber
Erik Kerber

Reputation: 5656

Sleep causes the current thread to sleep for the specified amount of time. Join will wait (block) the current thread until the referenced thread completes.

Upvotes: 5

Related Questions