user944197
user944197

Reputation:

Where does a thread end?

I'm currently learning c# and would like to know where it ends, is it at the t.Start or does is continue from there or should I call a other method from the threadMethod? Thanks in advance.

private void startThread()
{
    Thread t = new Thread(new ThreadStart(threadMethod));
    t.Start();
}

private void threadMethod()
{
    //do stuff
}

Upvotes: 1

Views: 337

Answers (3)

zeebonk
zeebonk

Reputation: 5034

A thread stops when its method has finished or fails, in your case threadMethod().

Upvotes: 4

RollRoll
RollRoll

Reputation: 8462

the thread ends when the threadMethod ends. Notice that by executing threadMethod asynchronously startThread() is going to finish before the threadMethod().

it is probably a good idea to study the multi-threading concept first before going forward with c# ( or at least doing both together ) it will things way easier and faster for you to get to learn

good luck

Upvotes: 0

Tigran
Tigran

Reputation: 62246

Thread normally ends when threadMethod stops its execution.

Upvotes: 3

Related Questions