Threads problem

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Philip Greer

    Threads problem

    I am getting the following issue with a first threads program I've written:

    root@aixsys1:/usr/local/bin # ./threadtest.pl
    Thread 1 with 0 and 10 to do something...
    Can't call method "tid" without a package or object reference at
    /usr/opt/perl5/lib/5.8.2/aix-thread-multi/threads.pm line 57.
    A thread exited while 2 threads were running.

    The script as is follows:

    #!/usr/bin/perl

    use threads;

    sub mythread
    {
    my $arg1 = shift;
    my $arg2 = shift;
    my $myself = threads->self;
    my $threadid = $myself->tid;

    print "Thread $threadid with $arg1 and $arg2 to do something...\n" ;
    sleep 30;
    }

    MYLOOP: foreach (0 ... 100)
    {
    if (threads->list == 10) {sleep 30; redo MYLOOP;}
    $a=$_;
    $b=$_ + 10;
    $mythread = threads->create("mythre ad",($a,$b));
    }



    What am I doing wrong?

    I want to keep 10 threads going at all times.

    Thanks,
    Philip
Working...