#! perl -sw use threads; my $n = 0; while( 1 ) { ++$n; my $obj1 = Class->new(); my $obj2 = Class->new(); warn "\nMAIN[0]: Creating thread $n passing objs: $obj1 & $obj2\n"; threads->create( \&thread_sub, $obj1, $obj2, 0 ); sleep 10; } sub thread_sub { my( $obj1, $obj2, $level ) = @_; warn "THREAD[@{[ threads->tid ]}] L:$level running\n"; sleep 2; threads->create( \&thread_sub, $obj1, $obj2, $level + 1 ) unless $level; sleep 2; warn "THREAD[@{[ threads->tid ]}] L:$level finished\n"; threads->self->detach; } 1; package Class; use threads::shared; my %refcounts; sub new { my $pkg = shift; my $this = {}; bless $this, $pkg; } sub CLONE { warn ">CLONE[@{[ threads->tid ]}]:\n"; my $this = shift; # not applicable warn "tid ]}]: this; $this\n"; } sub DESTROY { warn ">DESTROY[@{[ threads->tid ]}]:\n"; my $this = shift; warn "tid ]}]: this: $this\n"; } 1; #### C:\test>junk10 MAIN[0]: Creating thread 1 passing objs: Class=HASH(0x2683c0) & Class=HASH(0x2c4e50) >CLONE[1]: CLONE[2]: DESTROY[1]: DESTROY[1]: DESTROY[2]: DESTROY[2]: DESTROY[0]: DESTROY[0]: