Categories

Jun 25, 2019 in Dot Net

Q:

What is a Thread? What is Multithreading?

1 Answer

Jun 25, 2019

Thread is a set of instructions that can be executed, which will enable our program to perform concurrent processing. Concurrent processing helps us do more than one operation at a time. By default, C# has only one thread. But the other threads can be created to execute the code in parallel with the original thread.

Thread has a life cycle. It starts whenever a thread class is created and is terminated after the execution. System.Threading is the namespace which needs to be included to create threads and use its members.

Threads are created by extending the Thread Class. Start() method is used to begin thread execution.

//CallThread is the target method//
 ThreadStart methodThread = new ThreadStart(CallThread);
 Thread childThread = new Thread(methodThread);
 childThread.Start();

C# can execute more than one task at a time. This is done by handling different processes by different threads. This is called MultiThreading.

There are several thread methods that are used to handle the multi-threaded operations:

Start, Sleep, Abort, Suspend, Resume and Join.

Most of these methods are self-explanatory.

Click here to read more about Loan/Mortgage
Click here to read more about Insurance

Related questions

Madanswer
Jun 25, 2019 in Dot Net
Jun 25, 2019 in Dot Net
Jun 25, 2019 in Dot Net
...