1,277
edits
Changes
→Question 3 - WaitUntil(): concurrent editing ftw
==Question 3 - WaitUntil()==
;Implementation:
Alarm has a new sorted PriorityQueue waitingThreads to keep track of when waiting threads should be woken, sorted on their wake times from lowest to highest.
It also has a new inner class named waitingThread which contains a reference to the KThread and its associated wakeTime(long).
waitUntil(time){
WaitingThread wt = new WaitingThread (currentThread, currentTime + time);
}
;Testing:
For or while loop that prints out a series of statements. Check that statements for different threads are all printed contiguously according to their respective wake times.
==Question 4 - Communicator==