use strict; use warnings; use threads; my $str = 'x' x 32_000_000; sub fork_wait { my $pid = fork; if ($pid) { wait; } else { substr( $str, $_, 1 ) &= ~ (' 'x1000) for 0 .. (length( $str )/1000) -1; exit 0; } } sub create_thread_join { threads->create( sub { substr( $str, $_, 1 ) &= ~ (' 'x1000) for 0 .. (length( $str )/1000) -1; } )->join; } use Benchmark qw( cmpthese ); cmpthese - 3, { Forks => \&fork_wait, Threads => \&create_thread_join, };