#!/usr/bin/perl -w use strict; use threads; use threads::shared; use Cache::File::Heap; my $heap = Cache::File::Heap->new('frontier'); my $heap_lock : shared = 0; ... sub go {#crawling thread's control flow .... #xtracted best promising url { lock $heap_lock; my($value, $url) = $heap->extract_minimum; } ... #after downloading and extract hyperlinks { lock $heap_lock; $heap->add($value, $url) for } ... } my @threads; for(1..10) { push @threads, threads->new(\&go); } for(@threads) { $_->join; }