عرض عملي: مجمّع خيوط يُسقط العمل بصمت
في هذا الدرس 3 موضوعات
هذا الدرس مخطط له. يعرض المخطط أدناه الموضوعات التي سيغطيها، ولم يُنشر الدرس الكامل بعد.
نص الدروس والتمارين باللغة الإنجليزية، بينما تبقى واجهة الموقع وعناوين الدروس بالعربية.
في هذا الدرس
find lost tasks caused by a rejection policy and swallowed errors.
تفاصيل المخطط المبدئي
خطوة بخطوة
- Start a pool with 2 threads, a queue of 2, and
DiscardPolicy. - Submit 10 slow tasks; count completions: only 4 finish, with no error.
- Switch to
AbortPolicy; catchRejectedExecutionExceptionand see the rejected count. - Planned mistake: use
submitwith a task that throws and never callget(); the failure vanishes. Fix: wrap the task body in try/catch with logging, or inspect the futures. - Decide a policy: caller-runs for backpressure or abort plus metric; never silent discard for business work.
التطبيق
طبّق هذا الدرس بمختبر الوحدة وتمارينها واختبارها.
تعليم الدرس كمكتمل اختياري ويمكنك التراجع عنه في أي وقت. يبقى تقدمك محفوظًا في هذا المتصفح.