5:22 am GMT
Examples
Examples » Ada
with Text_IO; use Text_IO;
procedure Tasks is
task type Char_Printer( Ch: Character );
task Printer is
entry Print_Two( Ch: in Character );
end Printer;
task body Printer is
begin
loop
select
accept Print_Two( Ch: in Character )
do
Put( Ch );
delay 0.1;
Put( Ch );
New_Line;
end Print_Two;
or
terminate;
end select;
end loop;
end Printer;
task body Char_Printer is
begin
for I in 1..10 loop
Printer.Print_Two( Ch );
end loop;
end Char_Printer;
Task1: Char_Printer( '*' );
Task2: Char_Printer( '+' );
begin -- main "Tasks " routine
null; -- Nothing to do here!
end Tasks;
This category contains 3
examples, and has been viewed 41897 times.
|