COMMUNITY

Is neko web do not support Thread?

haxe-neko

(Mr Zhan) #1

is neko web do not support Thread?

nekotools server -p 2000 -h 10.143.26.11 -d ./

I try to compile neko and set for my http server ,and run this code

Thread.create(threadListen)

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

is neko web not support thread?


(Luke) #2

When you create a thread, it is created separate from the main thread, so any calls you make on the second thread will operate on the second thread, but all your results are being fed through the main thread so the function call is redundant at that point. You need to send and read messages between the main and secondary threads in order to get the results you want.

Check out the following archived tutorial.


(Mr Zhan) #3

thank you ,