# New Ticket Created by  Dave Rolsky 
# Please include the string:  [perl #127243]
# in the subject line of all future correspondence about this issue. 
# <URL: https://rt.perl.org/Ticket/Display.html?id=127243 >


Here's an example which might demonstrate why this is important:

class C {
    has @.threads;
    method foo {
        @!threads = (^10).map: {
            Thread.start(
                name => $_,
                sub {
                    sleep 1;
                    say $*THREAD.name;
                }
            )
        };
        say @!threads;
    };
    submethod DESTROY {
        say 'bye';
        .finish for @!threads;
    };
};

my $c = C.new;
$c.foo;
exit 0;

While there are various workarounds, it seems like that all force the _user_ of 
the class to explicitly account for the need to cleanup threads created by C. 
It seems like a class should be fully self-contained and capable of cleaning up 
after itself.

Reply via email to