<?xml version="1.0" encoding="windows-1252"?>
<node id="671203" title="Re: multi threading" created="2008-02-29 11:16:56" updated="2008-02-29 06:16:56">
<type id="11">
note</type>
<author id="485015">
renodino</author>
<data>
<field name="doctext">
&lt;blockquote&gt;&lt;i&gt;some kinda synchronized processing&lt;/i&gt;&lt;/blockquote&gt;
&lt;p&gt;
Er...threads have enough problems with non-deterministic behavior,
you might want to refine that "requirement" a bit ?
&lt;p&gt;
And I spotted a rather gruesome wart in the midst of your example:
invoking &lt;pre&gt;system("date")&lt;/pre&gt; from inside a thread is not exactly
best practice (&lt;i&gt;you do realize system() turns into a fork()?&lt;/i&gt;).
Consider using 
&lt;code&gt;
print "test\n", scalar localtime(), "\n";
&lt;/code&gt;
instead.
&lt;p&gt;
Of course, making that edit changes the whole behavior of the threads: since its much faster, many threads will complete before other threads have
even been started...so its not exactly simultaneous.
&lt;p&gt;
As [BrowserUk] mentioned, look into lock() and cond_wait().

&lt;!-- Node text goes above. Div tags should contain sig only --&gt;
&lt;div class="pmsig"&gt;&lt;div class="pmsig-485015"&gt;
&lt;hr&gt;&lt;/hr&gt;
&lt;i&gt;&lt;small&gt;Perl Contrarian &amp;amp; SQL fanboy&lt;/small&gt;&lt;/i&gt;
&lt;/div&gt;&lt;/div&gt;</field>
<field name="root_node">
671087</field>
<field name="parent_node">
671087</field>
</data>
</node>
