ReentrantLock เป็นการล็อกที่ชัดเจนจาก java.util.concurrent.locks ซึ่งเป็นทางเลือกที่ยืดหยุ่นกว่าในการซิงโครไนซ์ "Reentrant" หมายความว่าเธรดที่ยึดล็อคสามารถดึงกลับมาได้อีกครั้งโดยไม่มีการล็อคตาย ข้อได้เปรียบที่สำคัญ: tryLock พร้อมการหมดเวลา การรอแบบขัดจังหวะ โหมดยุติธรรม และออบเจ็กต์ Condition แยกกัน

ReentrantLock เทียบกับการซิงโครไนซ์
Full content is available with a subscription.
Get full access to all courses on the platform for one year with a single payment.
Unlike other platforms that charge per course, here you get everything for one price, and after one year of use there will be no automatic charge for the following year.