hi every1, I write this snippet so as to do priority for everyone queue, but what's wrong with join? Actually in POSIX C-lang I use pthread_join, I've read docs about perl thread, but still complicated why happening so funky things with that? Also for input values into testing log I do echo 4-2-67-1 >> tst.log.
use threads; my %queue; file_watchdog(); exit 1; sub file_watchdog { open(TRAP, '<tst.log') or die "can't open file_watchdog!"; while (1) { select(undef,undef,undef,0.2); my $a .= <TRAP>; if(length($a) gt 0 ){ checker($a); } } close (TRAP); } sub checker { my ($y) = @_; if($y =~ /(\d+)\-(\d+)\-(\d+)\-(\d+)/){ my $ip =$1; my $idx= $2; my $time = $3; my $th = $4; my $thr_h; $queue{$ip}{$idx}{TICK} = $time; if($time < 5 ){ my $wait = 7-$time; $queue{$ip}{$idx}{WAIT} = $wait; print "IP:$ip IDX:$idx TIME:$time TH:$th WAIT:$wait \n"; if($th){ #Thread 2 terminated abnormally: Not a CODE reference + at thread.pl line 34, <TRAP> line 2. $thr_h->{$ip} = threads->create(\&wait_q($ip,$idx)); #->join() +; }else{ wait_q($ip,$idx); } }else{ if ($thr_h->{$ip}->is_joinable()) {#Can't call method "is_join +able" on an undefined value at thread.pl line 40, <TRAP> line 3. $thr_h->{$ip}->join(); } print "do_connection() IP:$ip\n"; } } } sub wait_q { my $ip = shift; my $idx = shift; sleep( $queue{$ip}{$idx}{WAIT} ); oid_checker($ip); }

In reply to threads join() by gants

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.