For Programmers: Free Programming Magazines  


Home > Archive > ithreads > June 2005 > Re[2]: programming multithreaded applications in perl









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author Re[2]: programming multithreaded applications in perl
du4mi@gmx.de

2005-06-08, 9:03 pm

Hello Robert,

Friday, June 18, 2004, 12:54:37 PM, Robert Friberg wrote:

RF> Excerpt from perlthrtut:

RF> The ideal way to reduce these costs is to have a
RF> relatively short number of long-lived threads, all created fairly early on -
RF> before the base thread has accumulated too much data.


good, I am trying to do this way: creating a worker-thread without modules
in BEGIN{} block. The problem is how can main programm and this thread
communicate with each other and share variables, arrays and hashes?
Using shared variables not working for me. I have something like this:

BEGIN{
use strict;
use threads;
use threads::shared;
use warnings;

threads->new("worker"); #

sub worker {
while (1) {
# do something
sleep(1);
}
}

}
use strict;
use warnings;
use Win32::Internet; # some modules
use DBI;
use Win32::Clipboard;
use MIME::Base64;
use Compress::Zlib;
use Win32;
use Win32::Sound;
use Tie::IxHash;
while(1){
# do something
sleep 1;
}
--
Best regards,
du4mi mailto:du4mi@gmx.de

Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2008 codecomments.com