in reply to Re^6: Threads question
in thread Threads question
#!/usr/bin/perl use warnings; use strict; use threads; use threads::shared; my $count = 0; while (1) { $count++; print "thread $count started\n"; my $t = threads->new(\&do_my_thing, $count)->detach; sleep 5; } sub do_my_thing { use LWP::Simple; use Data::Dumper; use HTML::TokeParser::Simple; my $get = 'http://google.com'; my $page=get( $get ); my $p = HTML::TokeParser::Simple->new( \$page ); while ( my $token = $p->get_token ) { # This prints all text in an HTML doc (strips HTML) next unless $token->is_text; print $token->as_is; } my $val = shift; select(undef,undef,undef,.1); print "thread $val ended\n"; }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^8: Threads question
by BrowserUk (Patriarch) on Jun 30, 2007 at 17:13 UTC |