Do I need to kill a thread written like this? Or will it automatically end? Do I need to kill a thread written like this? Or will it automatically end? multithreading multithreading

Do I need to kill a thread written like this? Or will it automatically end?


That's fine... if it's a concern that the Thread might not complete before your executable quits, you might want:

new Thread(() =>    {        function();    }){IsBackground = true}.Start();

Background threads will not prevent your app from exiting.


Yes, the thread will end after the function completes, but unless you have a parameter you need to use inside the function I wouldn't start it like that; I would just do:

new Thread(function).Start();


Although it's considered best practise to manage your threads, if you aren't interested in the result/state of that particular thread and don't need to deal with cancellation etc. then what your doing is fine.

It's worth considering whether or not you need a dedicated thread for what you're doing. If the code you are running is relatively small you might want to consider utilising the ThreadPool via the TPL or QueueUserWorkItem instead.