5 if ($ENV{'PERL_CORE'}){
7 unshift @INC, '../lib';
10 if (! $Config{'useithreads'}) {
11 print("1..0 # Skip: Perl not compiled with 'useithreads'\n");
16 use ExtUtils::testlib;
23 print("1..29\n"); ### Number of tests that will be run ###
37 # You have to do it this way or VMS will get confused.
39 print("ok $id - $name\n");
41 print("not ok $id - $name\n");
42 printf("# Failed test at line %d\n", (caller)[2]);
49 ### Start of Testing ###
51 # Tests freeing the Perl interperter for each thread
52 # See http://www.nntp.perl.org/group/perl.perl5.porters/110772 for details
58 my $tid = threads->tid();
59 ok($tid, "Thread $tid started");
63 threads->create('threading_1')->detach();
83 ok($tid, "Thread $tid done");
88 threads->create('threading_1')->detach();
106 ok($COUNT == 5, "Done - $COUNT threads");
110 my $tid = threads->tid();
111 ok($tid, "Thread $tid started");
114 threads->create('threading_2')->detach();
123 ok($tid, "Thread $tid done");
128 threads->create('threading_2')->detach();
138 ok($COUNT == 5, "Done - $COUNT threads");
142 threads->create(sub { })->join();
148 my $tid = threads->tid();
149 ok($tid, "Thread $tid started");
152 threads->create(sub {
153 my $tid = threads->tid();
154 ok($tid, "Thread $tid started");
163 ok($tid, "Thread $tid done");
171 ok($tid, "Thread $tid done");
176 threads->create(sub {
177 threads->create('threading_3')->detach();
188 ok($COUNT == 2, "Done - $COUNT threads");