> I want to use thread in perl on windows NT.
> My code is not working.. If anybody knows about this let me know..
> 
> use Thread;
> $thr = new Thread \&sub1,"A","B";
> sub sub1 {
>    my @inparameter = @_;
>    print "@inpparameter \n";
> }
> 
> IF i run this code ..It gives me error below..
> ERROR :
> This perl was built for "ithreads", which currently does not support
> Thread.pm. Run "perldoc Thread" for more information at th.pl line 4.

Did you run perldoc Thread?

Thread is an old obsolete Perl 5.005 thing.

The development of new Threads module for Perl 5.6 with iThreads 
is under development but currently only runs under very recent 
development versions of perl.

You can of course create threads without it. fork() in reality creates 
threads under ActivePerl 5.6 (or any perl compiled with iThreads)

so this code actualy creates two threads :
        
        $pid = fork();
        die "Cannot fork() : $!" unless defined $pid;
        if ($pid) {
                print "Hello I am the parent thread\n";
                sleep(10);
        } else {
                print "Hello I am the child thread\n";
                sleep(9);
        }

You may check via "Tesk Manager" that this script will not produce 
two processes, but only onew with two threads.

Read perldoc perlfork

There are still some problems with iThreads though. One of them is 
presented here http://jenda.krynicky.cz/iThreads.html

HTH, Jenda

P.S.: I have written a script with one main and several worker 
threads where the main thread sends commands to the children via 
a pipe and any free child accepts the command and acts 
accordingly. Works great. I'll clean it up, comment it and post it 
online soon as an example.


== [EMAIL PROTECTED] == http://Jenda.Krynicky.cz ==
: What do people think?
What, do people think?  :-)
             -- Larry Wall in <[EMAIL PROTECTED]>
_______________________________________________
ActivePerl mailing list
[EMAIL PROTECTED]
http://listserv.ActiveState.com/mailman/listinfo/activeperl

Reply via email to