#!/usr/bin/perl use warnings; use strict; use Time::HiRes qw[ time ]; use threads; use threads::shared; use Data::Dumper; my $href = &share({}); sub sub1 { sleep 1; print threads->tid(), ' : ', time, $/; print Dumper $href; print threads->tid(), ' : ', time, $/; } $href->{a} = &share({}); print threads->tid(), ' : ', time, $/; my $th1 = threads->new('sub1'); print threads->tid(), ' : ', time, $/; $href->{b} = &share({}); print threads->tid(), ' : ', time, $/; my $th2 = threads->new('sub1'); print threads->tid(), ' : ', time, $/; $th1->join(); $th2->join(); #### C:\test>junk2 0 : 1227891440.24088 } 0 : 1227891440.26269 } 22 milliseconds to start a thread 0 : 1227891440.26288 0 : 1227891440.28761 } 24 milliseconds to start a thread 1 : 1227891441.27213 } $VAR1 = { 'a' => {}, 'b' => {} }; 1 : 1227891441.27275 } 62 microseconds to dump the hash 2 : 1227891441.28775 } $VAR1 = { 'a' => {}, 'b' => {} }; 2 : 1227891441.28835 } 60 microseconds to dump the hash