-#!perl
+#!./perl
BEGIN {
chdir 't' if -d 't';
@INC = '../lib';
require Config; import Config;
- if ($Config{'ccflags'} !~ /-DUSE_THREADS\b/) {
+ if (! $Config{'usethreads'}) {
print "1..0\n";
exit 0;
}
}
$| = 1;
-print "1..9\n";
+print "1..12\n";
use Thread;
print "ok 1\n";
use attrs 'locked';
my $val = shift;
my $ret;
+ print $val;
if (@_)
{
- $ret = new Thread \&islocked,shift;
- sleep 2;
+ $ret = Thread->new(\&islocked, @_);
+ join $ret;
}
- print $val;
}
-$t = islocked("ok 6\n","ok 7\n");
+$t = new Thread \&islocked, map { "ok $_\n" } 6..10;
+sleep 2;
join $t;
# test that sleep lets other thread run
-$t = new Thread \&islocked,"ok 8\n";
-sleep 2;
-print "ok 9";
+$t = new Thread \&islocked,"ok 11\n";
+sleep 6;
+print "ok 12\n";
join $t;