how to execute two function same time in perl by threads? -
i new thread concept in perl, how can execute 2 function same time in perl? how can start concept?
my script:
use strict; use warnings; &one; &two; sub one{ print $_, " " (1..10); } sub two{ print $_, "\n" (1..10); } output: 1 1 2 2 3 3 4 4 5 5 ... ...
how can run 2 function same time threads or , other way... ?
my output:
welcome (01:12 am) welcome (01:12 am)
thanks advance...
use threads; $t = async { one() }; two(); $t->join();
you won't nice output without synchronisation, though.
Comments
Post a Comment