Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # from man perlthrtut merged with Camel 3rd example
- # (according to book Thread::Queue is build on cond_wait)
- use threads;
- use Thread::Queue;
- my $Q = Thread::Queue->new();
- my $thr = threads->create(sub {
- while (my $el = $Q->dequeue()) {
- print("Popped $el off the queue\n");
- }
- });
- $Q->enqueue(12);
- $Q->enqueue("A", "B", "C");
- sleep(3);
- $Q->enqueue(\%ENV);
- $Q->enqueue(undef);
- $thr->join();
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement