package body Workers is
   protected body Tally is
      procedure Add (N : Natural) is
      begin
         if Total < 1000 then
            Total := Total + N;
         end if;
         if Count < 4 then
            Count := Count + 1;
         end if;
         Done := Count = 4;
      end Add;
      entry Wait_All (Sum : out Natural) when Done is
      begin
         Sum := Total;
      end Wait_All;
   end Tally;
   task body Worker is
   begin
      Tally.Add (Id);
   end Worker;
end Workers;
