with Ada.Text_IO; use Ada.Text_IO;

procedure Task1 is
   task type T1 (Index : Integer) is
      entry Start;
      entry E1;
      entry E2;
   end T1;

   type T1_Ptr is access T1;

   T : array (1 .. 5) of T1_Ptr;

   task body T1 is
   begin
      accept Start;
      Put_Line ("T" & Index'Img & " is starting...");

      loop
         Put_Line ("in T" & Index'Img);
         delay 1.0;
      end loop;
   end T1;

begin
   for J in 1 .. 5 loop
      T (J) := new T1 (J);
   end loop;

   for J in 1 .. 5 loop
      T (J).Start;
   end loop;
end Task1;
