#! perl -slw use strict; use threads; use threads::shared; our $N ||= 1000; our $aClonedGlobal = 12345; my $aClonedLexical = 12345; our $aSharedGlobal :shared = 12345; my $aSharedLexical :shared = 12345; my $running :shared = 0; for ( 1 .. $N ) { async{ { lock $running; ++$running } my $tid = threads->self->tid; my( $some, $thread, $local, $vars ) = (12345) x 4; require Carp; require IO::Socket; require Time::HiRes; print "$tid: $aClonedGlobal : $aClonedLexical : $aSharedGlobal : $aSharedLexical"; { lock $running; --$running }; }->detach; } sleep 1 while $running;