in reply to Re^9: Should I use threads? Perl/DHCP/Radius
in thread Should I use threads? Perl/DHCP/Radius

One question : What is the difference between a thread updating a shared hash and exiting (A) and a thread joining the main process with return data (B).

A couple of thoughts on this.

One of the drawbacks of threads, is that if a thread calls "exit".... it will take down the entire process, all other threads will exit too. I think you mean detach instead of exit.

Secondly, when a thread updates a shared hash, none of the other threads see the update, until they actually try to read it themselves. This is why I like timers so much in the main thread. It can repeatedly loop thru share hashes and update the shared values. As far as I know, there is no tie in shared hashes, that would be a neat feature.

One of the often overlooked aspects of threads, is that in order for a thread to be joined OR detach and dissappear, is that the thread must either

1. reach the end of it's code block or

2. return

So you need to design your threads to finish properly, or they may never join or detach successfully..... they may hang around and give an error like " program exited with 3 threads still running"


I'm not really a human, but I play one on earth.
Old Perl Programmer Haiku ................... flash japh
  • Comment on Re^10: Should I use threads? Perl/DHCP/Radius