#!perl -w use strict; use threads (); my $test_thread; BEGIN { # start thread before modules are loaded in order to # prevent unnecessary copying of data to thread $|=1; $test_thread = threads->new(sub {for (1..10) { print "$_\n"; sleep 1;}}); } use Math::BigInt; use IO::Handle; my $bi1 = Math::BigInt->new('1234567890'); my $bi2 = Math::BigInt->new('2345678901'); sleep 3; # give $test_thread some time to start up STDOUT->autoflush(1); print $bi2->bsub($bi1) . "\n"; $test_thread->join();