perl thread

 1 #!/usr/local/bin/perl   
 2 use threads;   
 3 
 4 @domain   =   ("tom.com",   "chinadns.com",   "163.com",   "aol.com");   
 5 for ($i=0;$i<4;$i++)
 6 {   
 7     print   $i.'.'.$domain[$i].'     ';   
 8 }   
 9 print   "\n";   
10     
11 my   $thr0   =   threads->new(\&checkwhois,   '0',   $domain[0]);   
12 my   $thr1   =   threads->new(\&checkwhois,   '1',   $domain[1]);   
13 my   $thr2   =   threads->new(\&checkwhois,   '2',   $domain[2]);   
14 my   $thr3   =   threads->new(\&checkwhois,   '3',   $domain[3]);   
15     
16 sub   checkwhois()   
17 {   
18     my ($l,$r)=@_;   
19     my $i=0;   
20     while($i<1000000)   
21     {   
22           $i*$i;   
23           $i++;   
24     }   
25     print   "done  --$l\t\n";   
26     print   $l.$r."   query   successful!   \n";    
27 }
28 
29 $thr0->join;  
30 $thr1->join;   
31 $thr2->join;   
32 $thr3->join; 

 

posted on 2013-11-22 15:33  海神若风  阅读(225)  评论(0)    收藏  举报

导航