Perl Threads implementation so far, seems very inadequate - it is good for primary school student exhibiting how parallel programming works.

That is a wrong conclusion drawn through a lack of understanding.

If you would care to describe your application in detail -- not just generics, but rather scales and reasons; with examples of data and processing requirements -- then you would (probably) get help with finding definitive, practical and efficient solutions to those requirements.

Your OP asks a simplistic question with an obvious answer: Yes, of course a multi-level hash can be constructed using multiple threads. It is simple and trivial:

#! perl -slw use strict; use threads; use threads::shared; sub displayHash { my( $ref, $pad ) = @_; return "\n" unless keys %{ $ref }; my $buf = ''; for my $key ( sort keys %{ $ref } ) { $buf .= "$pad" if length $buf; $buf .= "{$key}" . displayHash( $ref->{ $key }, $pad . ' ' ) +; } return $buf; } sub worker { my( $ref, $reps ) = @_; for( 1 .. $reps ) { my $copyRef = $ref; for my $step ( map chr( 97 + rand 26 ), 1 .. int( rand 10 ) ) +{ if( exists $copyRef->{ $step } ) { $copyRef = $copyRef->{ $step }; } else { lock %{ $copyRef }; $copyRef = $copyRef->{ $step } = &share( {} ); } } } } our $REPS //= 20; our $THREADS //= 4; my %HoHos : shared; my @threads = map threads->create( \&worker, \%HoHos, $REPS ), 1 .. $T +HREADS; $_->join for @threads; print displayHash( \%HoHos, '' ); __END__ C:\test>junk91 -REPS=7 {b}{l}{w}{g} {d}{t}{k}{f}{g}{g}{g}{i}{j} {f}{j}{v} {g}{s}{g}{h}{g} {i}{f}{j}{r}{m}{v}{u}{v}{b} {k}{d}{f}{q}{k} {z}{t}{m}{h}{e}{i} {m}{b}{l} {l}{u}{p}{t}{d}{h} {q}{k}{y} {n}{f}{u}{v}{z}{z}{l} {o}{f} {p}{u}{s}{w}{n}{t} {q}{h} {y}{k}{d}{l}{a}{n}{a}{i} {r}{q}{t}{g} {v}{o}{n}{x}{b}{g}{c} {w}{a} {y}{a} {d}{y}{j} {z}{a}{p}{t}{i}{r}{t} {y}{i}{g}{c}{v}{z}{z}{k}

But, it is also probably not very helpful to your real application.


With the rise and rise of 'Social' network sites: 'Computers are making people easier to use everyday'
Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
"Science is about questioning the status quo. Questioning authority".
In the absence of evidence, opinion is indistinguishable from prejudice.

In reply to Re^3: Is it possible to create a single Hash-of-Hash.. with multiple threads.. by BrowserUk
in thread Is it possible to create a single Hash-of-Hash.. with multiple threads.. by gsat

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.