C# - Part 86 - Thread.Join() method and IsAlive property - Tutorial For Beginners

Опубликовано: 12 Март 2025
на канале: parvesh
29
2

Join blocks the current thread and makes it wait until the thread on which Join method is invoked completes.

Join method also has a overload where we can specify the timeout. If we don't specify the timeout the calling thread waits indefinitely, until the thread on which Join() is invoked completes.

This overloaded Join(int milliseconds Timeout) method returns boolean. True if the thread has terminated otherwise false.

Join is particularly useful when we need to wait and collect result from a thread execution or if we need to do some clean-up after the thread has completed.

IsAlive returns boolean. True if the thread is still executing otherwise false.