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