-- Chapter 29 - Program 3
with Ada.Text_IO;
use Ada.Text_IO;
procedure TaskAces is
task type SHORT_LINE is
end SHORT_LINE;
task type LONG_LINE is
end LONG_LINE;
type LONG_POINT is access LONG_LINE;
Cow, Dog, Pig : SHORT_LINE;
Elephant, Hippopotamus : LONG_POINT;
task body SHORT_LINE is
begin
for Index in 1..4 loop
delay 0.0;
Put_Line("This is a short line");
end loop;
end SHORT_LINE;
task body LONG_LINE is
begin
for Index in 1..3 loop
delay 0.0;
Put_Line("This is a much longer line to be displayed");
end loop;
end LONG_LINE;
begin
Put_Line("This is an example of use of a task type");
Elephant := new LONG_LINE;
Hippopotamus := new LONG_LINE;
end TaskAces;
-- Result of execution
-- This is an example of use of a task type
-- This is a short line
-- This is a short line
-- This is a short line
-- This is a short line
-- This is a short line
-- This is a short line
-- This is a much longer line to be displayed
-- This is a short line
-- This is a short line
-- This is a short line
-- This is a much longer line to be displayed
-- This is a short line
-- This is a short line
-- This is a short line
-- This is a much longer line to be displayed
-- This is a much longer line to be displayed
-- This is a much longer line to be displayed
-- This is a much longer line to be displayed