Fork: Difference between revisions
Content added Content deleted
No edit summary |
m (→{{header|Phix}}: added syntax colouring, marked p2js incompatible) |
||
Line 1,257: | Line 1,257: | ||
Phix has create_thread which creates a separate thread, with its own call stack, but sharing common data (like most fork examples here).<br> |
Phix has create_thread which creates a separate thread, with its own call stack, but sharing common data (like most fork examples here).<br> |
||
To run something completely independently, use system() or system_exec(), depending on whether you want a shell and/or to wait for a result. |
To run something completely independently, use system() or system_exec(), depending on whether you want a shell and/or to wait for a result. |
||
<!--<lang Phix>(notonline)--> |
|||
⚫ | |||
<span style="color: #008080;">without</span> <span style="color: #008080;">js</span> |
|||
<lang Phix>procedure mythread() |
|||
<span style="color: #008080;">procedure</span> <span style="color: #000000;">mythread</span><span style="color: #0000FF;">()</span> |
|||
?"mythread" |
|||
<span style="color: #0000FF;">?</span><span style="color: #008000;">"mythread"</span> |
|||
exit_thread(0) |
|||
<span style="color: #000000;">exit_thread</span><span style="color: #0000FF;">(</span><span style="color: #000000;">0</span><span style="color: #0000FF;">)</span> |
|||
end procedure |
|||
<span style="color: #008080;">end</span> <span style="color: #008080;">procedure</span> |
|||
⚫ | |||
atom hThread = create_thread(routine_id("mythread"),{}) |
|||
<span style="color: #004080;">atom</span> <span style="color: #000000;">hThread</span> <span style="color: #0000FF;">=</span> <span style="color: #000000;">create_thread</span><span style="color: #0000FF;">(</span><span style="color: #7060A8;">routine_id</span><span style="color: #0000FF;">(</span><span style="color: #008000;">"mythread"</span><span style="color: #0000FF;">),{})</span> |
|||
?"main carries on" |
|||
<span style="color: #0000FF;">?</span><span style="color: #008000;">"main carries on"</span> |
|||
wait_thread(hThread)</lang> |
|||
<span style="color: #000000;">wait_thread</span><span style="color: #0000FF;">(</span><span style="color: #000000;">hThread</span><span style="color: #0000FF;">)</span> |
|||
<!--</lang>--> |
|||
or |
or |
||
<lang Phix> |
<!--<lang Phix>(notonline)--> |
||
<span style="color: #008080;">without</span> <span style="color: #008080;">js</span> |
|||
<span style="color: #7060A8;">system</span><span style="color: #0000FF;">(</span><span style="color: #008000;">"calc"</span><span style="color: #0000FF;">)</span> |
|||
<!--</lang>--> |
|||
=={{header|PHP}}== |
=={{header|PHP}}== |