php class Singleton thread type

Asked

Viewed 57 times

0

I have a class that accesses the service layer of my application. This class is a Singleton. Through the service, it accesses the data in a uniform way, so that my application has the expected behavior. The problem is, I see the need for my class to also be a thread. That makes sense to you ? Thank you

class envio_massa extends Thread {
// atributos
private static $instance = NULL;


// construtor
private static function __construct() {
    ;
}

// funções

// singleton
public static function get_instance() {
    // Já existe uma instância
    if (self::$instance == NULL) {
        self::$instance = new envio_campanha_service();
    }

    return self::$instance;
}

// Previne o uso de clone
private function __clone() {}
public function run() {...}

}

  • This thread class does what? doesn’t make much sense, it’s best you provide more detail, remember that PHP doesn’t work with threads by default.

  • this class will access shipping data in the bank, so Singleton, and will send the data to customers, so threads. Can be many simultaneous shipments and do not want to leave the processor idle.

  • 1

    What about the thread? 'Cause she inherits it?

  • In order to explore the parallelism of the processor, but in this case, Singleton will not allow.

  • 1

    Your object ceases to exist in memory after the end of the webserver request. Why worry about all this ?

No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.