Perl Threads & Fork example

Skip to end of metadata
Go to start of metadata

Below you'll find an example of a multi-threaded Perl program as well as a forked Perl program.
Both seem to work fine. A disadvantage of threads is that Perl needs to be compiled with threads support.
Not all versions of Perl come with that by default.

A Perl Thread example

Will print:

Perl Fork example

This examples fork 10 child processes.
It will wait for all childs to finish before exiting.

Output looks like:

PHP fork example

here's the same fork example implemented in PHP

  • None