#!/usr/local/perl_ithreads/bin/perl use strict; use warnings; use threads; use threads::shared; my %h = ( a => 1, b => 2, c => 3 ); my @locking_keys = qw/ a b /; my $guard:shared; { lock( $guard ); ## Lock the guard ## do stuff with the hash cond_signal( $guard ); ## unlock the guard (atomic) }