use threads;
$| ++;
threads->create(\&a);
while (1) {}
sub a {
eval(threads->self->join);#Waiting for Godot
print "before return\n";#will not show up
}
####
use threads;
$| ++;
$child = threads->create(\&a);
$child->join; # I am wating the $child thread to finish first
print "Main thread stop\n";
sub a {
for (1..5) {
print "child is still counting, $_\n";
sleep(3);
}
print "child thread stop\n";
}
####
$| ++;
if (($chld = fork()) == 0) {
sleep(3);
print "child exit\n";
} else {
waitpid $chld, 0;
print "parent exit\n";
}
####
$| ++;
waitpid $$, 0; #wait for Godot
print "exit\n";