1,277
edits
Changes
m
→{{c|KThread.join()}}: formatting on impl
=={{c|KThread.join()}}==
===Implementation===
;New state variables{{c|KThread}} has a new state variable {{c|joinedOnMe}}, a {{c|ThreadQueue}}. ;Implementation details
* When {{c|threadA}} calls {{c|threadB.join()}}, {{c|threadB}} adds it to its internal {{c|joinedOnMe}} queue and then puts it to sleep. In {{c|threadB}}'s {{c|finish()}} method, {{c|threadB}} calls {{c|nextThread()}} on its {{c|joinedOnMe}} queue before returning.
* {{c|join()}} also checks that this thread is not equal to the current thread and that {{c|joinedOnMe}} is not already occupied by another thread with a boolean flag, which determines whether {{c|join()}} has already been called on this thread.