מערכות מידע נושאים מתקדמים בתכנות- עדכני

לחץ כאן לכל השאלות

מה הפלט של התוכנית הבאה?

1
done
Explanation: From the statement “thread.start()”, we have two threads Main thread and “thread” thread. So either “GFG” can be printed or “Geeks”, depend on which thread, thread scheduler schedule. For (a), the parent thread after calling start() method is paused and the thread scheduler schedules the child thread which then completes its execution. Following this, the parent thread is scheduled. For (b), the parent thread calls start() method but continues its execution and prints on the console. When join() method is called, the parent thread has to wait for its child to complete its execution. Thread scheduler schedules child thread while the parent waits for the child to complete.
by
מיין לפי

* השאלה נוספה בתאריך: 21-07-2019