Synchronicity of thread creation?

48 views
Skip to first unread message

Horsetopus

unread,
Jun 22, 2016, 7:23:47 AM6/22/16
to Haxe
Hi,

Considering this code:

class Client {

private var webSocket:WebSocket;
private var listeningThread:Thread; 

public function new( webSocket ):Void {

this.webSocket = webSocket;

listeningThread = Thread.create( function():Void {

while( true )
onMessage( this.webSocket.recv() );
} );
}
}

Can I be sure that the tread will be running at the time the instantiation of Client is finished, or should I add a security of some sort? ( call a function from the thread, or send a message )?

Sam MacPherson

unread,
Jun 22, 2016, 1:14:47 PM6/22/16
to Haxe
The thread should be created, but no code was necessarily executed.

Horsetopus

unread,
Jun 22, 2016, 1:27:21 PM6/22/16
to Haxe
Ok, thanks.
Reply all
Reply to author
Forward
0 new messages