Anyhow, I've got my previous question figured out; the threads were going out of scope apparently. If I push each thread onto an array, this code works. Is this correct?
use threads;
push @threads, threads->create(sub { sleep $i; return time(); })
while ($i++ < 5);
foreach $thr (threads->list) {
next if threads::equal($thr, threads->self);
push @results, $thr->join;
}
die "results undefined\n" unless (defined @results);
print $_, "\n" for (@results);
Jesse Butler - Sun Microsystems wrote:
I have a question regarding join(). If this is not the correct list, please let me know.
Simply put, join() doesn't seem to be returning anything. Below is my test code; what am I missing?
_______________________
use threads;
threads->create(sub { sleep $i; return time(); })
while ($i++ < 5);
foreach $thr (threads->list) {
next if threads::equal($thr, threads->self);
push @results, $thr->join;
}
die "results undefined\n" unless (defined @results);
print $_, "\n" for (@results);
________________________
This code always dies "results undefined". Any help (or bonks on the head) would be appreciated.
Regards,
Jesse