6 require Config; import Config;
7 unless ($Config{'useithreads'}) {
8 print "1..0 # Skip: might still hang\n";
17 $q = new threads::shared::queue;
22 my $tid = threads->self->tid;
26 # print "reader (tid $tid): waiting for element $i...\n";
29 # print "reader (tid $tid): dequeued element $i: value $el\n";
30 select(undef, undef, undef, rand(1));
33 # print "reader (tid $tid) returning\n";
42 for (my $i = 0; $i < $nthreads; $i++) {
43 push @threads, threads->new(\&reader, $i);
46 for (my $i = 1; $i <= 20; $i++) {
47 my $el = int(rand(100));
48 select(undef, undef, undef, rand(1));
49 # print "writer: enqueuing value $el\n";
53 $q->enqueue((-1) x $nthreads); # one end marker for each thread
56 # print "waiting for join\n";