且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

C#线程对象的生命周期

更新时间:2023-01-16 11:24:54

对象会立刻进行垃圾回收,因为它是不再使用,即调用后,立即启动方法。 (它将但不会立即作为垃圾收集器在特定时间运行收集。)

The Thread object will be eligible for garbage collection as soon as it's not used any more, i.e. immediately after calling the Start method. (It will however not be collected immediately, as the garbage collector runs at specific times.)

实际的线程但不依赖于主题对象,并将继续即使对象收集运行。

The actual thread however is not relying on the Thread object, and will continue to run even if the Thread object is collected.

如果线程仍在运行时的主要方法退出时,应用程序将不会结束,直到线程完成,除非您已标记线程是一个后台线程。

If the thread is still running when the main method exits, the application will not end until the thread completes, unless you have marked the thread to be a background thread.