Beefy Boxes and Bandwidth Generously Provided by pair Networks
go ahead... be a heretic
 
PerlMonks  

Re: Shared variable not changing?

by weismat (Friar)
on Mar 17, 2009 at 10:40 UTC ( #751143=note: print w/replies, xml ) Need Help??


in reply to Shared variable not changing?

You are hiding the shared queue, because you have a my @queue in your code.
Additionally there is no lock statement anywhere, thus this will never ever be thread-safe. If you want to extent Thread::Queue, you should first read the thread tutorial and look at the implementation of Thread::Queue in the lib directory.
I would suggest that you copy the enqueue code into a new function and change it to work inside the queue. The implementation of the Thread::Queue shows you the difficulty of working with threads in a safe way...

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://751143]
help
Chatterbox?
[Discipulus]: M4ver1k are you debug/dump vars in the loops? are you sure you are not quitting the loop earlier?
[Corion]: A good weekstart to everybody!
[Discipulus]: good morning nuns and monks! hello Corion

How do I use this? | Other CB clients
Other Users?
Others studying the Monastery: (4)
As of 2017-11-20 08:12 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    In order to be able to say "I know Perl", you must have:













    Results (285 votes). Check out past polls.

    Notices?