Question: 8 . 2 2 LAB: Timeout manager with PriorityQueue Timeout manager overview A timeout manager stores a priority queue of timeout items, each a (

8.22 LAB: Timeout manager with PriorityQueue
Timeout manager overview
A timeout manager stores a priority queue of timeout items, each a (callback method, callback time) pair. Ea method is called approximately N milliseconds after the timeout is set, where N is the delay specified when a timeout item. Ex:
At time t=0, a 500 millisecond timeout is set for method A
At time t=100, a 3000 millisecond timeout is set for method B
At time t=2000, a 1000 millisecond timeout i set for method C
So the timeout manager should call the callbacks as follows:
Call method A at time t=0+500=500
Call method C at time t=2000+1000=3000
Call method B at time t=100+3000=3100
A timeout item with a callback time the current time is said to be "expired".
Millisecond-level callback precision is often unfeasible. So a timeout manager typically has an update methor by external code every so often, ex: every 100 milliseconds. The manager's update method calls each expired callback method.
Step 1: Inspect Timeoutltem.java
Inspect the Timeoutltem class declaration in the read only Timeoutltem.java file. Access Timeoutltem.java b) orange arrow next to LabProgram.java at the top of the coding window. The callbackTime private field stol item was added plus the item's delay. Ex: A Timeoutltem created at t=500 with a delay of 1000 has callbackTi 1000=1500. The callbackMethod private field is the method to call after the timeout expires.
 8.22 LAB: Timeout manager with PriorityQueue Timeout manager overview A timeout

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!