6 require Config; import Config;
7 unless ($Config{'useithreads'}) {
8 print "1..0 # Skip: might still hang\n";
15 use threads::shared::queue;
17 $q = new threads::shared::queue;
21 my $test : shared = 1;
24 my $tid = threads->self->tid;
28 # print "reader (tid $tid): waiting for element $i...\n";
30 print "ok $test\n"; $test++;
31 # print "reader (tid $tid): dequeued element $i: value $el\n";
32 select(undef, undef, undef, rand(1));
35 # print "reader (tid $tid) returning\n";
44 for (my $i = 0; $i < $nthreads; $i++) {
45 push @threads, threads->new(\&reader, $i);
48 for (my $i = 1; $i <= 20; $i++) {
49 my $el = int(rand(100));
50 select(undef, undef, undef, rand(1));
51 # print "writer: enqueuing value $el\n";
55 $q->enqueue((-1) x $nthreads); # one end marker for each thread
58 # print "waiting for join\n";