File : counter_test.adb


with Ada.Text_IO        ; use Ada.Text_IO;
with Ada.Integer_Text_IO; use Ada.Integer_Text_IO;

procedure Counter_Test is

   Sum : Natural := 50;

   task type Counter (Goal : Natural);

   task body Counter is

   begin
      for I in 1..100 loop
         if Sum > Goal then
            Sum := Sum - 1;
         elsif Sum < Goal then
            Sum := Sum + 1;
         end if;
         delay 0.0; -- try leaving this delay out!
      end loop;

      Put( "Final value in Counter (task)"); Put(Sum); New_Line;
   end Counter;

   Counter_1 : Counter (40);
   Counter_2 : Counter (70);

begin
   Put( "Final value in Counter_Test "); Put(Sum); New_Line;
end Counter_Test;