Thread Pool ใน C# คือกลุ่มของ Threads ใช้ทำงานใน Background (Background Tasks) เมื่อ Thread ทำงานเสร็จ จะถูกส่งกลับ Queue เพื่อนำกลับมาใช้ใหม่ (Reuse)
วิธีสร้าง Thread Pool
- ใช้ Namespace:
using System.Threading; - เรียก ThreadPool Class ผ่าน Object ใช้เมธอด
QueueUserWorkItem:ThreadPool.QueueUserWorkItem(new WaitCallback(Run));
- Iterate ใน Loop และเปรียบเทียบกับ Thread ธรรมดา