in reply to Threading Equivalent to this Parallel::ForkManager Example
This would seem to be an equivalent:
#!/usr/bin/env perl use strict; use warnings; use threads;
while (<DATA>) { threads->create(sub { print 'Thread ', threads->tid, ': ', $_ })-> +join; }
Update: Apparently not equivalent - see BrowserUk's comments below.
__DATA__ list.txt line 1 list.txt line 2 list.txt line 3
Output:
Thread 1: list.txt line 1 Thread 2: list.txt line 2 Thread 3: list.txt line 3
The "Perl Threads Tutorial" would probably be a good place to start if you want to learn more.
-- Ken
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Threading Equivalent to this Parallel::ForkManager Example
by BrowserUk (Patriarch) on Apr 02, 2014 at 08:00 UTC | |
by kcott (Archbishop) on Apr 02, 2014 at 08:13 UTC |