I have a Perl script that launches 2 threads,one for each processor. I need it to wait for a thread to end, if one thread ends a new one is spawned. It seems that the join m
I think you need to move the code that pulls the next file from the list into the threads themselves.
So every thread would not just process one file, but continue to process until the list is empty.
This way, you also save on the overhead of creating new threads all the time.
Your main thread will then join both of them.
Of course, this requires synchronization on the list (so that they do not pull the same data). Alternately, you could split the list into two (one for each thread), but that might result in an unlucky distribution.
(PS: No Perl God, just a humble monk)