2 eval { require Config; import Config };
4 print "1..0 # Skip: no Config\n";
12 $q = new Thread::Queue;
15 my $tid = Thread->self->tid;
19 print "reader (tid $tid): waiting for element $i...\n";
21 print "reader (tid $tid): dequeued element $i: value $el\n";
22 select(undef, undef, undef, rand(2));
25 print "reader (tid $tid) returning\n";
33 for (my $i = 0; $i < $nthreads; $i++) {
34 Thread->new(\&reader, $i);
37 for (my $i = 1; $i <= 10; $i++) {
38 my $el = int(rand(100));
39 select(undef, undef, undef, rand(2));
40 print "writer: enqueuing value $el\n";
44 $q->enqueue((-1) x $nthreads); # one end marker for each thread