#!/usr/bin/perl use warnings; use threads; use threads::shared; use Thread::Barrier; my $br = Thread::Barrier->new; my $thr1 = threads->new(\&req); $thr1->join; sub req { $count=0; print "Enter number: "; $num = ; my @thrlist; for (1..$num) #create number of threads { $thrlist[$_] = threads->new(sub { print"test\n"; system("date"); }); $thrlist[$_]->join; $count++; } foreach (threads->list){ $br->wait; } print $br->wait; print "\n\ntotal number of threads $count\n\n"; }