2 eval { require Config; import Config };
4 print "1..0 # Skip: no Config\n";
7 if ($Config{extensions} !~ /\bThread\b/) {
8 print "1..0 # Skip: no use5005threads\n";
16 $q = new Thread::Queue;
19 my $tid = Thread->self->tid;
23 print "reader (tid $tid): waiting for element $i...\n";
25 print "reader (tid $tid): dequeued element $i: value $el\n";
26 select(undef, undef, undef, rand(2));
29 print "reader (tid $tid) returning\n";
37 for (my $i = 0; $i < $nthreads; $i++) {
38 Thread->new(\&reader, $i);
41 for (my $i = 1; $i <= 10; $i++) {
42 my $el = int(rand(100));
43 select(undef, undef, undef, rand(2));
44 print "writer: enqueuing value $el\n";
48 $q->enqueue((-1) x $nthreads); # one end marker for each thread