الخيوط ودورة حياتها
في هذا الدرس 4 موضوعات
هذا الدرس مخطط له. يعرض المخطط أدناه الموضوعات التي سيغطيها، ولم يُنشر الدرس الكامل بعد.
نص الدروس والتمارين باللغة الإنجليزية، بينما تبقى واجهة الموقع وعناوين الدروس بالعربية.
في هذا الدرس
create threads and read their states.
الموضوعات المخطط لها
Threadruns aRunnable; callstart(), neverrun()directly.- States: NEW, RUNNABLE, BLOCKED (waiting for a monitor), WAITING and TIMED_WAITING (
wait,join,sleep), TERMINATED. join()waits for a thread to finish;interrupt()requests it to stop, and blocking calls throwInterruptedException.- Handle interruption: restore the flag or exit; never swallow it.
- Raw threads are rarely created in services; executors manage them.
تفاصيل المخطط المبدئي
عرض عملي
Thread t = new Thread(() -> importPrices("acme"));
t.start();
t.join();اختبر فهمك
What does calling run() instead of start() do?
أظهر الإجابة
Runs on the calling thread; no new thread.
التطبيق
طبّق هذا الدرس بمختبر الوحدة وتمارينها واختبارها.
تعليم الدرس كمكتمل اختياري ويمكنك التراجع عنه في أي وقت. يبقى تقدمك محفوظًا في هذا المتصفح.