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.
– rray
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.
– willian rodrigues andrade
What about the thread? 'Cause she inherits it?
– rray
In order to explore the parallelism of the processor, but in this case, Singleton will not allow.
– willian rodrigues andrade
Your object ceases to exist in memory after the end of the webserver request. Why worry about all this ?
– gmsantos