一個簡單的任務和兩個迴圈
with Ada.Text_IO; use Ada.Text_IO;
procedure Main is
task My_Task;
task body My_Task is
begin
for I in 1 .. 4 loop
Put_Line ("Hello from My_Task");
end loop;
end;
begin
for I in 1 .. 4 loop
Put_Line ("Hello from Main");
end loop;
end;
結果
Put_Line
的順序可以變化。
Hello from My_Task
Hello from My_Task
Hello from Main
Hello from My_Task
Hello from Main
Hello from My_Task
Hello from Main
Hello from Main