with Text_IO, Ada.Integer_Text_IO; use Text_IO, Ada.Integer_Text_IO; with Ada.Strings.Unbounded; use Ada.Strings.Unbounded; with Ada.Float_Text_IO; use Ada.Float_Text_IO; procedure Ctest1 is X : Integer := 0; -- shared var task type Loopingtask is entry Start(I : Integer); end Loopingtask; task body Loopingtask is V : Integer := 0; -- local var Id : Integer; -- id assigned by start. begin accept Start(I : Integer) do Id := I; Put(Id,Width=>2); Put(": Loopingtask starting..."); New_Line; end Start; while (V<100000) loop Put(Id,Width=>2); Put(" local var is "); Put(V); New_Line; Put(Id,Width=>2); Put(" gobal var is "); Put(X); New_Line; V := V+1; X := X+1; end loop; end Loopingtask; type Tptr is access Loopingtask; A, B : Tptr; begin A := new Loopingtask; -- note: not new Tptr! B := new Loopingtask; A.Start(1); B.Start(2); end Ctest1; -- the use of pointers allows us to create tasks/threads dynamically, only -- when we need to. Otherwise, the task is created and starts to execute -- as soon as it's declared.