Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我读了 producer/consumer queue implementation Producer/Consumer Queue。它工作得很好,但我担心如果客户忘记调用 Shutdown()。我应该如何实现工作线程的释放?谢谢。
如果要关闭程序时调用 Shutdown(),则可以在创建线程时将它们标记为后台线程。这意味着它们将在程序关闭时停止,但并不总是理想的,因为线程可以强制终止。
Thread t = new Thread() t.IsBackground = true;