Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl: the Markov chain saw

Comment on

( #3333=superdoc: print w/replies, xml ) Need Help??
I need a way to pause multithreaded Tkx application (threads are collecting some data via HTTP). Threads push data to the queue so the main application can read it (and show to the user). Customer want to pause the program if one of the threads find some data. By pause i mean stop updating text log widget. Here is code:
sub start { my @result; $queue= Thread::Queue->new; $queue_processed = Thread::Queue->new; my @domains = get_domains($domains_filename); $queue->enqueue(@domains); my @threads= map { threads->create( sub { create_thread($_) } ) } +( 1 .. $CONFIG{NUMBER_OF_THREADS} ); $_->detach for (@threads); my $counter = 0; while ( $counter < scalar @domains ) { my $result = $queue_processed->dequeue_nb; if ($result) { $txt_processed_domains->configure(-state => "normal"); $txt_processed_domains->insert_end( "$result" ); $txt_processed_domains->see("end"); $txt_processed_domains->configure(-state => "disabled"); Tkx::update(); $counter++; } } Tkx::tk___messageBox( -message => "Completed!" ); }
So i have one problem: how to pause all running threads (and continue them after some user actions)?

In reply to How to pause multithreaded application? by Gangabass

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, 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, 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.
  • Log In?

    What's my password?
    Create A New User
    and all is quiet...

    How do I use this? | Other CB clients
    Other Users?
    Others cooling their heels in the Monastery: (6)
    As of 2018-06-18 08:26 GMT
    Find Nodes?
      Voting Booth?
      Should cpanminus be part of the standard Perl release?

      Results (109 votes). Check out past polls.