Re: How do you share an object(Telnet Sesion) between threads?

Steve Cookson - gmail <[email protected]> Thu, 01 Oct 2015 09:51:57 +0100
Newsgroups gmane.comp.lang.perl.wxperl
Message-ID <[email protected]>
Sorry, I forgot you were talking about communicating between threads.

On 30/09/15 18:15, James Lynes wrote:
> The Monks said basically you can't do that. Not supported by 
> threads::shared. Only references to shared scalers are supported. 
> Possibly a convoluted way to manipulate object internals. Several have 
> tried in the past with limited success.

Why do you need multiple threads?  I did have that at one stage, but in 
the end I found that the computer just kept starting threads until the 
cpu was running at 100%.

If the threads are:

Connect
Scan
Disconnect,

Maybe you could design it differently.  I guess you only want to run one 
at a time, eg if you are not connected you can connect, but if you are 
already connected, you don't want to connect again, and the same for 
disconnect.  You can only scan if you are connected.

In which case you have only one or zero threads starting and stopping, 
but no communication between threads.

Whenever I've had multiple threads, they have been completely 
independent from one another, like go process a video snapshot and tell 
me when you are done (ie pass a status back).

If you really must have communication between threads, you can use a 
file or a database.

Regards

Steve.