Results 1 to 5 of 5

Thread: The problem with Pthread class

Hybrid View

  1. #1
    Join Date
    Apr 2014

    Question The problem with Pthread class

    Hi everyone
    I have written a piece of code like the following
    I used the front of the class: http://www.php.net/manual/en/book.pthreads.php
    The goal is the end result is the sum = 2003
    But I get an error message.
    Is it possible to modify this piece of code for me.
    Thank you And sorry for my illiteracy.

    PHP Code:
    class my extends Thread {

      public function 
    $this->arg $arg;

      public function 
    $temp $this->arg;
    $i = ($this->arg) + 1000;
    $j[$temp] = $i;
    $j = array(
    my('1'), new my('2')

    $thread $j[0];

    $thread $j[1];

    $sum $j[0] + $j[1];

  2. #2
    Join Date
    Aug 2004
    What is the exact error you are getting?
    "Well done....Consciousness to sarcasm in five seconds!" ~ Terry Pratchett, Night Watch

    How to Ask Questions the Smart Way (not affiliated with this site, but well worth reading)

    My Blog
    cwrBlog: simple, no-database PHP blogging framework

  3. #3
    Join Date
    Apr 2014
    hi & tank you very much.

    The main problem is, I can't access to
    PHP Code:
    [$ temp]; 
    in outside the class ...

    in class i can "echo $j[1];" and output = 1001


    Outside the the class:
    i cant, and have error like this:
    Catchable fatal error: Object of class my could not be converted to integer in C:\Program Files\EasyPHP-DevServer-14.1VC9\data\localweb\test\test3.php on line 30
    my output:
    PHP Code:
    1001 /* in my class*/
    1002 /* in my class*/

    Catchable fatal errorObject of class my could not be converted to integer in C:\Program Files\EasyPHP-DevServer-14.1VC9\data\localweb\test\test3.php on line 30 /* outside of my class*/ 

  4. #4
    Join Date
    Dec 2002
    Seattle, WA
    you are trying to add my class to my class
    PHP Code:
    $sum $j[0] + $j[1]; 
    PHP Code:
    $sum $j[0]->arg $j[1]->arg

  5. #5
    Join Date
    Apr 2014
    Thank you very much for your answer.

    with proposed code my output: = > 3

    But I am looking for = > 2003

    I think,There is not accessible outside of class

    I had to change my own question:

    To be part of a student project should do something like the following:

    8 threads in a three-dimensional array is sorted.
    In the first step, each 8 threads use for 8 act (Like: act sum)
    In the second step 4 threads to be use for 4 act (Like: act sum)

    With these conditions,
    The previous code can not be used
    now I have no idea for it...

    Can you Help me, please
    How do I sort threads in array?
    and then access the threads with array value...
    like: $array[1] -> thread1 do...

    Unfortunately in this case, there is no source of my official language
    And my English is very poor,
    But happy to answer my questions I got here.
    Thank you very much.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
HTML5 Development Center