I need to know how to implement multi threading for the following code . I need to call this script every second but the sleep timer processes it after 2 seconds . In total script call itself after every 3 seconds. But i need to call it every second , can anybody provide me a solution to it or point me to right direction.
#!usr/bin/perl
use warnings;
sub print
{
local $gg = time;
print "$gg\n";
}
$oldtime = (time + 1);
while(1)
{
if(time > $oldtime)
{
&print();
sleep 2;
$oldtime = (time + 1);
}
}
Its just an example.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With