say $*THREAD;
Thread.start(
name => 'Sleep 3 seconds',
sub {
say $*THREAD;
sleep 3;
say 1;
}
);
Thread.start(
name => 'Sleep 2 seconds',
sub {
say $*THREAD;
sleep 2;
say 2;
}
);
Thread.start(
name => 'Sleep 1 second',
sub {
say $*THREAD;
sleep 1;
say 3;
}
)
say $*THREAD;
my $t1 = Thread.start(name => 'Test 1', sub {say $*THREAD});
my $t2 = Thread.start(name => 'Test 2', sub {say $*THREAD});
my $t3 = Thread.start(name => 'Test 3', sub {say $*THREAD});
say $t1.WHAT;
say $t2.WHAT;
say $t3.WHAT;
my $t = Thread.new(
name => 'My thread',
code => sub {
say 'Start';
sleep 2;
say 'End';
}
);
say 'Before';
$t.run();
say 'After';
Thread.start(sub {
.say for 1..5;
});
Thread.start(sub {
.say for 11..15;
});