عرض عملي: تشخيص جمود متبادل من thread dump
في هذا الدرس 3 موضوعات
هذا الدرس مخطط له. يعرض المخطط أدناه الموضوعات التي سيغطيها، ولم يُنشر الدرس الكامل بعد.
نص الدروس والتمارين باللغة الإنجليزية، بينما تبقى واجهة الموقع وعناوين الدروس بالعربية.
في هذا الدرس
read a thread dump and fix the cause.
تفاصيل المخطط المبدئي
خطوة بخطوة
- Run a Shop
transfer(from, to)that locks both accounts in argument order; fire opposite transfers concurrently. - The app hangs; take a dump with
jcmd <pid> Thread.print. - Find the "Found one Java-level deadlock" section; read which thread holds which lock and waits for which.
- Planned mistake: restart the app and call it solved. Fix: record the dump, identify the lock order, then fix it.
- Apply ordered locking (lower id first) and rerun the stress test; no hang.
التطبيق
طبّق هذا الدرس بمختبر الوحدة وتمارينها واختبارها.
تعليم الدرس كمكتمل اختياري ويمكنك التراجع عنه في أي وقت. يبقى تقدمك محفوظًا في هذا المتصفح.