ASSIGNMENTS for Lab Session 4


  1. 1

    Write a demonstration program to show how it is possible to make use of ScheduledExecutorService to run delayed, periodic, and spaced tasks. The task body can be minimal (e.g., the display of a message).

  2. 2

    Design and implement a class MyTimer to be used to measure time intervals in the executions of programs. The supported methods must be at least start(), stop(), clear(), and read().

  3. 3

    Develop a program to accurately measure the runtime of a portion of code, represented by the method "foo". Time intervals can be measured using the class MyTimer. In the case of Java code, getting meaningful figures is quite complicated, because of the behavior of the supporting platform. Thus, in a real setting, this overall scheme has to be significantly improved with specific tricks.