"Niklas Holsti" wrote in message news:c8ljhpFaqrfU4@mid.individual.net... > On 14-09-26 10:58 , J-P. Rosen wrote: >> Le 26/09/2014 09:04, Björn Lundin a écrit : >>> Or by using a protected object as a semaphore >>> >> But why? It's so simpler with a task: >> >> task Printer is >> entry Print (Mess : String); >> end Printer; > > The semaphore solution lets one group related output lines together; the > task+entry (in the above form) can interleave output lines from > different tasks, perhaps making output harder to read. Whether this > matters depends on what one needs. Right. Note that the semaphore ought to be wrapped in a Limited_Controlled object so that it gets unlocked if the scope is exited by an exception. That's especially important for protecting I/O, since I/O routines have a tendency to propagate an exception because of full disks, permissions errors, etc. Without such protection, an exception would leave the semaphore locked and you'll end up with deadlock as no task can do any I/O. (The task version probably ought to be protected from exceptions as well, I'll leave that as an exercise for the reader.) Randy.