Jump to content

Check out our Community Blogs


Member Since 18 Jan 2011
Offline Last Active Sep 13 2011 03:10 PM

Topics I've Started

Multithreading Shared Objects

18 January 2011 - 04:50 AM

I'm trying to share an object in a multithreaded script. I can't use:

my $x : shared new TestObbj (1);

So, I tried using a pointer to the variable as an argument to the spawning of the thread:

my $Test = new TestObj (1);
my $TestPtr = \$Test;
my $tid1 = new threads(\&Child1, $TestPtr);

When I print out the value of the pointer inside the thread, it is not the same value as in the main thread. What am I doing wrong?

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download