C# Thread Join, IsAlive, Abort

C# Code Snippets Thread Join IsAlive Abort
Share:

About

In this code snippet, we will take a look at thread join, isAlive and abort in C#.

join() The main(parent) thread waits for the joined threads(threads that had the join() method called on them) to complete their execution before proceeding with its execution.

abort() Can be used to abort the thread execution. For example, if a thread takes to long to finish we can abort its execution. When this method is called on a thread it will throw a ThreadAbortException that will stop the thread. However, it’s not guaranteed that a thread will stop in all situations.

isAlive() Checks if the thread is running and returns true or false.

Let’s have a look at the code below to see how to use thread join, isAlive and abort.

Code:

Resulting output:

Share:

Leave a Reply

Your email address will not be published.

The following GDPR rules must be read and accepted:
This form collects your name, email and content so that we can keep track of the comments placed on the website. For more info check our privacy policy where you will get more info on where, how and why we store your data.

Advertisment ad adsense adlogger