note
zentara
There are just some very general comments one can make about Perl threads. <p>
The first is not all modules are thread safe, so be cautious when using module code across threads. Many modules are fine though, it depends. Google if in doubt.
<p>Second, since Perl scripts are run by interpreter, memory allocations made by a thread, will be kept by the mother process for later use. So memory gains can be
problem. So if you need to reclaim memory during the whole process, it is better to fork.
<p>Third, since Perl threads are made by a copy-on-create method, where the thread is a copy of the mother process at the time of creation, the threads can get alot of useless crud in them, and tend to be slow starting up.
<p>Fourth, it pays to design to reuse your threads. Make the threads once, then just reset them and feed them new data. This is a general way of improving performance and avoiding problems which come from spawning many many threads. But sometimes spawing and detaching works fine. YMMV
<p>Fifth, Perl threads are best suited for situations where you need realtime sharing of data between threads, using shared thread variables. Any other use can usually be done cleaner with a fork.
<p>Signals can be tricky. The mother thread receives all signals, and it is up to you
to pass it on to the correct thread.
<p>I'm just an amateur, and I tend to manually control my threads, but are some useful examples of mine and other monks:
[id://923647] .... [id://865662] .... [id://925269] ... [id://904811] .... [id://662931] ... [id://465380] .... [id://691785]
<p>Those ought to get you started. :-) Good luck.<p>P.S. As you google for examples, look for the answers from [BrowserUk]. He has the best understanding.
<!-- Node text goes above. Div tags should contain sig only -->
<div class="pmsig"><div class="pmsig-131741">
<hr />
I'm not really a human, but I play one on earth.<br>
[id://630805] ................... <a href=http://zentara.net/japh.html> flash japh </a>
</div></div>
1082113
1082113