انتقل إلى المحتوى
أمين أبوزيد
درس مخطط لهMID-006-L01

Future مقابل CompletableFuture

  • الدرس 1 من 6
  • Mid-level
في هذا الدرس 4 موضوعات

هذا الدرس مخطط له. يعرض المخطط أدناه الموضوعات التي سيغطيها، ولم يُنشر الدرس الكامل بعد.

نص الدروس والتمارين باللغة الإنجليزية، بينما تبقى واجهة الموقع وعناوين الدروس بالعربية.

في هذا الدرس

see why Future is limiting and what CompletableFuture adds.

الموضوعات المخطط لها

  • Future.get() blocks; there is no way to say "when done, do X".
  • CompletableFuture<T> is a future you can chain, combine, and complete manually.
  • supplyAsync runs a value-producing task; runAsync a no-result task.
  • Each stage returns a new future; build a pipeline instead of blocking.
  • Block only at the edge of the system, if at all.
تفاصيل المخطط المبدئي

عرض عملي

java
CompletableFuture<Product> p = CompletableFuture.supplyAsync(() -> productClient.get(id), ioPool);

اختبر فهمك

What can a CompletableFuture do that Future cannot?

أظهر الإجابة

Chain callbacks and combine results without blocking.

التطبيق

طبّق هذا الدرس بمختبر الوحدة وتمارينها واختبارها.

المختبر والتمارين الاختبار

تعليم الدرس كمكتمل اختياري ويمكنك التراجع عنه في أي وقت. يبقى تقدمك محفوظًا في هذا المتصفح.

اكتب للبحث في المستويات والمراحل والوحدات والدروس.