|
You could try having the main thread wait on a shared variable prior to attempting the join. The easiest way to do this with using Thread::Queue. Start with:
use threads;
use Thread::Queue;
my $DONE = Thread::Queue->new();
Have the thread code end by putting its TID onto the done queue:
$DONE->enqueue(threads->tid());
return (...);
In the main code, wait for the thread to finish before attempting a join:
my $tid = $DONE->dequeue();
threads->object($tid)->join();
|