sub start { my $self = shift; while (1) { last unless $self->do_one_loop(); } } #### use threads; ... my $thread = threads->new(sub { $aim->start }); $aim->send_im($victim, $msg);