1. with Ada.Text_IO;                 use Ada.Text_IO; 
  2. with Protected_Element_Generic; 
  3. with Unprotected_Element_Generic; 
  4.  
  5. procedure Count_Up is 
  6.  
  7. begin 
  8.    for i in 1 .. 20 loop 
  9.       declare 
  10.          package Protected_Natural is new Protected_Element_Generic 
  11.            (Element => Natural, Init => 0); 
  12.          package Unprotected_Natural is new Unprotected_Element_Generic 
  13.            (Element => Natural, Init => 0); 
  14.  
  15.          use Protected_Natural; 
  16.          use Unprotected_Natural; 
  17.  
  18.          task type Count_up_by (Difference : Natural) is 
  19.             entry Done; 
  20.          end Count_up_by; 
  21.  
  22.          task body Count_up_by is 
  23.  
  24.          begin 
  25.             for i in 1 .. Difference loop 
  26.                Unprotected_Element.Inc; 
  27.             end loop; 
  28.  
  29.             for i in 1 .. Difference loop 
  30.                Protected_Element.Inc; 
  31.             end loop; 
  32.  
  33.             accept Done; 
  34.          end Count_up_by; 
  35.  
  36.          Counters : array (1 .. 10) of Count_up_by (1_000); 
  37.  
  38.       begin 
  39.          for t of Counters loop 
  40.             t.Done; 
  41.          end loop; 
  42.  
  43.          Put_Line ("Protected value:" & Natural'Image (Protected_Element.Get) & 
  44.               " - Unprotected value:" & Natural'Image (Unprotected_Element.Get)); 
  45.       end; 
  46.    end loop; 
  47. end Count_Up;