Thread 1 terminated abnormally: lock can only be used on shared values at UTP.pm line 189 Do you think this is because of the separate package ?? I declare and initialise the hash in MdAgent.pl : ... my %Totals :shared; ... msg("initialising totals"); foreach my $envo(sort keys %{$marketMsgHsh{$plugin}{environments}}) { $DEBUG && msg("sharing $envo"); $Totals{$envo}=&share( {} ); $DEBUG && msg("done."); foreach my $messageType(sort keys %{$marketMsgHsh{$plugin}{messageTypes}}) { $Totals{$envo}{$messageType}=0; } } msg("done."); ... #### ... $mcastReaderThread=threads->create(\&doMcastSubscription, $interface, +$mcastAddress, $mcastPort); $mcastReaderThread->detach(); ... #### ... while(1) { $drop=1 unless $peer->recv($sock, $message, $maxLen,0) if($drop ==1) { $DEBUG && msg("recv failed : $!"); } else { $actualPlugin->processMessage("$message"); } ... #### ... if($FeedAgent::sendRateStats) { lock %{$Totals{$serviceID}}; $Totals{$serviceID}{$packetType}++; $DEBUG && msg("set Totals{$serviceID}{$packetType} == $Totals{$serviceID}{$packetType}");; } ...