#!/opt/coolstack/bin/perl use strict; use threads ('yield', 'stack_size' => 64*4096, 'exit' => 'threads_only', 'stringify'); use Thread::Queue; my $nloaders = 64; #--------------------------------------------------------------- my @thrs_loaders; my $queue = Thread::Queue->new(); for(1..$nloaders){ print "START LOAD $_ \n"; my ($thr) = threads->create(\&load, $_); push @thrs_loaders ,$thr; } $_->join for @thrs_loaders; exit; #--------------------------------------------------------------------- sub load{ my $id = shift; my $tmp; for(1..1e3){ my %rec = ('key_1' => 'val_1', 'key_2' => 'val_2'); $queue->enqueue(\%rec); # This give me an error: Invalid value for shared scalar } print "STOP $id\n"; }