Beefy Boxes and Bandwidth Generously Provided by pair Networks
No such thing as a small change
 
PerlMonks  

Re^2: Perl how to join all threads

by kamrul (Acolyte)
on Jul 06, 2015 at 21:52 UTC ( [id://1133454]=note: print w/replies, xml ) Need Help??


in reply to Re: Perl how to join all threads
in thread Perl how to join all threads

Hi.. thanks for your reply. I just found the problem is causing due to one thread. I have no problem if I turn that off. The function proc1 is using Thread::Queue. I tested without proc1 and it doesnt create any problem. Code of proc1 is like the below:
sub proc1 { $q = Thread::Queue->new(); while($p = $q->dequeue()){ if($p eq 'exit'){ last; } ..... } $q->end(); threads->exit(); }

Replies are listed 'Best First'.
Re^3: Perl how to join all threads
by BrowserUk (Patriarch) on Jul 06, 2015 at 22:14 UTC

    This: $q->dequeue() blocks internally on a cond_wait(), if no data is available in the queue. Signals will not interrupt threads::cond_wait().

    That said, how will that queue ever receive anything?

    It is created inside the thread and immediately goes into a dequeue(). As it was created inside the thread, no other thread has a handle to it, so no data can ever be queued to it.

    Your design is broken.


    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.
    I'm with torvalds on this Agile (and TDD) debunked I told'em LLVM was the way to go. But did they listen!

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://1133454]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others studying the Monastery: (5)
As of 2024-03-29 13:15 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found