Next | 4.2 Thread::Semaphore | Prev |
Semaphores provide a mechanism to regulate access to resources.
Semaphores don't limit their values to zero or one, so they can be used to control access to some resource that there may be more than one of.use Thread::Semaphore; my $s = new Thread::Semaphore; $s->up; # The guarded section is here $s->down;
my $s = new Thread::Semaphore(6); # default is 1 $s->up(2); $s->down(1); $s->down(1);
Next | Perl Threads | Prev |