1. with Ada.Text_IO;                 use Ada.Text_IO; 
  2. with Ada.Calendar;                use Ada.Calendar; 
  3. with Exceptions;                  use Exceptions; 
  4.  
  5. pragma Elaborate_All (Exceptions); 
  6.  
  7. package body Dynamic_Tasks is 
  8.  
  9.    Start_Up_Time       : constant Time     := Clock; 
  10.    No_of_Iterations    : constant Positive := 4; 
  11.    Delay_Per_Iteration : constant Duration := 1.0; 
  12.  
  13.    subtype Repeat_for is Positive range 1 .. No_of_Iterations; 
  14.  
  15.    task body Dynamic_Task is 
  16.  
  17.    begin 
  18.       accept Start; 
  19.  
  20.       if Id = 2 then 
  21.          raise Dynamic_Task_is_not_too_well; 
  22.       end if; 
  23.  
  24.       for i in Repeat_for loop 
  25.          Put_Line ("Task" & Dynamic_Id_Range'Image (Id) & " at" & Duration'Image (Clock - Start_Up_Time) & " seconds since start up"); 
  26.          delay Delay_Per_Iteration; 
  27.       end loop; 
  28.  
  29.    exception -- test what happens if you leave these two lines out. 
  30.       when X_Id : others => Show_Exception (X_Id); 
  31.  
  32.    end Dynamic_Task; 
  33.  
  34. end Dynamic_Tasks;