54 lines
1.2 KiB
Ada
54 lines
1.2 KiB
Ada
with Ada.Text_IO;
|
|
|
|
procedure tasks is
|
|
package to renames Ada.Text_IO;
|
|
|
|
task type counter1 is
|
|
entry Greet(s: String);
|
|
end;
|
|
|
|
task type counter2 is
|
|
entry Greet(s: String);
|
|
end;
|
|
|
|
task body counter1 is
|
|
begin
|
|
loop
|
|
select
|
|
accept Greet(s: String) do
|
|
to.Put("Task 1 accepted greeting string: ");
|
|
to.Put_Line(s);
|
|
end Greet;
|
|
to.Put_Line("Task 1 loop counter");
|
|
or
|
|
terminate;
|
|
end select;
|
|
to.Put_Line("Task 1 finish");
|
|
end loop;
|
|
end counter1;
|
|
|
|
task body counter2 is
|
|
begin
|
|
loop
|
|
select
|
|
accept Greet(s: String) do
|
|
to.Put("Task 2 accepted greeting string: ");
|
|
to.Put_Line(s);
|
|
end Greet;
|
|
to.Put_Line("Task 2 loop counter");
|
|
or
|
|
terminate;
|
|
end select;
|
|
to.Put_Line("Task 2 finish");
|
|
end loop;
|
|
end counter2;
|
|
|
|
c1: counter1;
|
|
c2: counter2;
|
|
|
|
begin
|
|
c1.greet("Ala 1");
|
|
c2.greet("Ala 2");
|
|
to.Put_Line("Tasks finished");
|
|
end tasks;
|