[EN] Python multi-threaded programming

This article discusses Python multi-threaded programming. Compiled from the website tutorialspoint.com (Make this article a memo). Running multiple threads is like running several different programs at the same time, but it’s useful:

  • Each thread can share the memory with the main thread and can communicate with each other.
  • Threads are smaller processes because they consume less memory than process calls.

[TH] Python multi-threaded programming

บทความนี้กล่าวถึงการเขียนโปรแกรมแบบหลายเธรดของภาษาไพธอน โดยเรียบเรียงจากเว็บไซต์ tutorialspoint.com (ทำให้บทความนี้เป็นเสมือนบันทึกช่วยจำ) ซึ่งการเรียกใช้หลายเธรดเปรียบเสมือนการเรียกใช้โปรแกรมที่แตกต่างกันหลายโปรแกรมพร้อมกันแต่มีประโยชน์ดังนี้

  • แต่ละเธรดสามารถใช้หน่วยความจำร่วมกันกับเธรดหลัก และสามารถสื่อสารระหว่างกันได้
  • เธรดเป็นโปรเซสที่มีขนาดเล็กเนื่องจากไม่สิ้นเปลือง over head (หน่วยความจำ) ของการเรียกใช้เหมือนการเรียกโปรเซสเพิ่ม