COMMUNITY

How to use Thread for php target?

haxe-php

(Mr Zhan) #1

how to use Thread for php target?
current I have some socket code use Tread class,

Thread.create(threadListen);

function threadListen() {
		while (true) {
			try {
				var text = socket.input.readLine();
				console.write(text + '\n');
			} catch (z:Dynamic) {
				console.write('Connection lost.\n');
				console.close();
				return;
			}
		}
	}

but Tread class only available neko,cpp,lua?
how to implement in php target ?


(Kevin Leung) #2

Is it possible to use thread in plain php?


(Mr Zhan) #3

may be php7.2 have


(david mouton) #4

More or less, The pthreads extension cannot be used in a web server environment. Threading in PHP is therefore restricted to CLI-based applications only.