What happens to this thread after the method completes?

In my ASP.NET application, while on the stack, I call the following code:

Public Shared Sub Larma(ByVal personId As Integer) Dim thread As New System.Threading.Thread(New ParametrizedThreadStart(AddressOf Larma_Thread)) thread.Start(personId) End Sub Private Shared Sub Larma_Thread(ByVal personId As Integer) StartaLarm(personId) Thread.Sleep(1000 * 30) StoppaLarm(personId) End Sub 

While this thread is running, the rest of the request is processed and the response is sent to the client. However, since I never call thread.Abort() or anything like that, and I am very inexperienced with threads in ASP.NET, I am worried that I am opening a memory leak or other threading issues.

What happens to a thread that starts with the code above after Larma_Thread completes?

0
multithreading
source share
2 answers

After the thread code completes execution, the thread will be stopped and its resources will be fixed.

+1
source share

The thread will be completed after your work is completed.

Please note that the thread may also be interrupted before your work is completed. IIS decides that it needs to rework the ASP.NET workflow.

+1
source share

All Articles