in reply to Re: The Singleton design pattern and fork();
in thread The Singleton design pattern and fork();
... my @flags : shared = (1) x 10; my @threads = threads->new( \&worker, \$_ ) for @flags; sleep 30; print 'Telling kids its time to go'; @flags = (0) x 10; ...
I know next to nothing about threads in perl, and i don't have 5.8 installed anywhere i can test this theory -- but threads or no threads i don't think that will do what you expect.
When you generate a reference to each value in @flags, and pass that to each new worker thread, you get a reference to those values -- even if you then blow away the contents of @flags later. The workers should still have references to the orriginal values.
Consider an unthreaded example...
laptop:~> perl -w -Mstrict -l my @foo = (1) x 10; my $ref = \$foo[3]; @foo = (0) x 10; print "ref is now: " . $$ref; ref is now: 1
Right? (Or is my lack of thread mojo causing me to missunderstand something major?)
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Re: Re: The Singleton design pattern and fork();
by BrowserUk (Patriarch) on Feb 22, 2003 at 12:46 UTC |